Results 1 to 3 of 3

Thread: Checking if running in PhoneGap or Mobile Web Browser

  1. #1
    Sencha User
    Join Date
    Aug 2009

    Default Checking if running in PhoneGap or Mobile Web Browser

    How do I check if the app is running in PhoneGap (or as native app) vs Mobile web browser (i.e. Safari)?

    For example in this pseudocode

    if (runningNatively) {
        enable camera-related UI
    } else {
        disable camera-related UI

    The reason I am asking is because I have a ST web app working and it's in production. I used the same code to build a sample iPhone app, but now I need to add native device functions, such as camera and push notification.

    I am debating whether I should use the same code base (modify one copy), but add checks at certain points in the app to integrate native phone functions, or should I make a copy, and maintain two separate code bases (Web app vs Native app).

    [EDIT] I guess I could always hardcode a global constant in index.html, then I maintain two index.html but one app.js. Still I'd like to know what others think.

  2. #2


    I'm also interested. - Software Development Blog

  3. #3
    Sencha User
    Join Date
    Jul 2010


    I use this in my app.js

    phoneGapAvailable: function() {
      return typeof(PhoneGap) != 'undefined';
    It has worked so far, but I haven't tested it thoroughly yet. Maybe someone has an alternative solution?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts