Note that there are some explanatory texts on larger screens.

plurals
  1. POPhoneGap: Detect if running on desktop browser
    primarykey
    data
    text
    <p>I'm developing a web application that uses PhoneGap:Build for a mobile version and want to have a single codebase for the 'desktop' and mobile versions. I want to be able to detect if PhoneGap calls will work (ie, is the user on a mobile device that will support PhoneGap).</p> <p>I've searched and cannot believe there is no simple way of doing this. Many people have offered suggestions;</p> <ul> <li><a href="http://www.sencha.com/forum/showthread.php?144127-Checking-if-running-in-PhoneGap-or-Mobile-Web-Browser">http://www.sencha.com/forum/showthread.php?144127-Checking-if-running-in-PhoneGap-or-Mobile-Web-Browser</a></li> <li><a href="http://groups.google.com/group/phonegap/browse_thread/thread/322e80bd41bb1a54/a421300eb2a2029f?lnk=gst&amp;q=detect+desktop#a421300eb2a2029f">http://groups.google.com/group/phonegap/browse_thread/thread/322e80bd41bb1a54/a421300eb2a2029f?lnk=gst&amp;q=detect+desktop#a421300eb2a2029f</a></li> <li><a href="http://groups.google.com/group/phonegap/browse_thread/thread/8a95dfeb0f313792/3ff10d8f35211739?lnk=gst&amp;q=detect+desktop+browser#3ff10d8f35211739">http://groups.google.com/group/phonegap/browse_thread/thread/8a95dfeb0f313792/3ff10d8f35211739?lnk=gst&amp;q=detect+desktop+browser#3ff10d8f35211739</a></li> </ul> <p>None of which work, unless you remove the PhoneGap Javascript file from the desktop version of the app, which defeats my goal of having one codebase.</p> <p>So far the only solution I have come up with is browser / user agent sniffing, but this is not robust to say the least. Any better solutions welcome!</p> <p>EDIT: A marginally better solution is to try calling a PhoneGap function after some small timeout - if it doesn't work, then assume the user is on a desktop web browser.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload