1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    395
    Vote Rating
    6
    gkatz is on a distinguished road

      0  

    Default sencha cordova native app & html app - what JS code can differentiate between the 2?

    sencha cordova native app & html app - what JS code can differentiate between the 2?


    hi all;
    I have a sencha html 5 app
    sometimes my app runs as a pure html 5 app via web browser and sometimes it runs compiled with cordova as a native app.
    I want my JS code (which si the exact same code in both permutations) to be able to differentiate between the 2 modes. what's the best practice for this? I am looking for something like:
    (is app native) ? get some resource : get other resource

    thanks in advance.

  2. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,964
    Vote Rating
    133
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    584
    Vote Rating
    32
    Kurt001 has a spectacular aura about Kurt001 has a spectacular aura about

      0  

    Default


    I think a good starting point is root/touch/src/device.
    Take a look at camera, which includes either cordova or a simulator fallback.
    You can use the same structure for your problem.

    Or you can go with the simple
    Code:
    var browserEnv = Ext.browser.is; 
    if (browserEnv.WebView && browserEnv.Cordova) {
        // Cordova stuff
    } else {
        // browser stuff
    }

  4. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    395
    Vote Rating
    6
    gkatz is on a distinguished road

      0  

    Default


    thanks guys!
    I will try that

Thread Participants: 2