Dreamweaver / Phonegab build service / device specific code

35 views
Skip to first unread message

doubledutch

unread,
Aug 6, 2012, 5:34:52 AM8/6/12
to phon...@googlegroups.com
I've been searching the www to find an answer to this question but it's just not obvious to me what the correct way of writing device specific code is using PhoneGap. So - Adobe dreamweaver now has single-button access to the Phonegap build service which is great but what is the proper way to configure my single code base application to choose between the right javascript code snippet below?

On Andoid: alert("Running on Android);
on iPhone:  alert("Running on iPhone);

Could someone describe that process to me?

Thanks in advance

Leon


Kerri Shotts

unread,
Aug 6, 2012, 5:58:12 AM8/6/12
to phon...@googlegroups.com, phon...@googlegroups.com
Use device.platform.


switch (device.platform.toLowerCase())
{
case "android": ...
                          break;
case "ipad":
case "iphone":
case "ipad simulator":
case "iphone simulator":
                          ...
                          break;
}

I would, suggest creating a function that coalesces all the iOS entries down into one element, unless you really need them separate. See my library in YASMF for an example: https://github.com/photokandyStudios/YASMF/blob/master/framework/device.js


______________________________
Kerri Shotts
photoKandy Studios LLC

📱 Phone: +1 (312) 380-1035
🌐 Web: http://photokandy.com 

Twitter: @photokandy

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
 
 

doubledutch

unread,
Aug 6, 2012, 11:54:38 AM8/6/12
to phon...@googlegroups.com
Hi Kerri - that's great. Another stupid question...

To use device.platform.toLowerCase() - I guess I have to add phonegap to my dreamweaver project. I tried not including anything but then device.platform.toLowerCase() doesn't do anything - so which files do I need to include to get this to work?

When I download phonegap 1.9.0 - it seems to contain a directory for every platform but just including the iOS version obviously defeats the point as I would like to include a generic file and based on the device.platform settings - use the platform specific one.

Or am I missing the point here?

Thanks

Leon

doubledutch

unread,
Aug 6, 2012, 6:31:03 PM8/6/12
to phon...@googlegroups.com
OK found my own answer here - you simply include an empty reference to:

<script src="phonegap.js" type="text/javascript" charset="utf-8"></script>

In your code and the phonegap builder does the rest. I never stumbled across this URL which contains loads of stuff https://build.phonegap.com/docs so hopefully that's helpful for others.

Leon
Reply all
Reply to author
Forward
0 new messages