0

Using an existing sencha project and PhoneGap Build, I have the problem that window.device is not defined if I query for it in the microloader/testing.js code.

Ext.blink = function(options) {
    ...
    Ext.microloaded = true;
    // Start my microloader enhancement
    isPhonegap = typeof window.device != "undefined";
    window.alert("isPhonegap: " + isPhonegap);

The config.xml contains the plugin:

<gap:plugin name="org.apache.cordova.device" />

Sencha is uploading everything to PhoneGap Build for me, it is built there, and then I download and adb install -r the resulting apk on my Android 4.0.4 Smartphone.

Result when starting the app, is the alert: isPhonegap: false.

What is the problem here?

Alexander
  • 19,906
  • 19
  • 75
  • 162

1 Answers1

1

Guessing a bit here, but could it be that you're calling that code before deviceReady has fired?

See http://docs.phonegap.com/en/4.0.0/cordova_events_events.md.html#deviceready for details.

geekonaut
  • 5,714
  • 2
  • 28
  • 30
  • As of now, I am using window.device to find out whether the app is running in phonegap container or in a real browser.Now I guess I have to find another way, because I should only wait for a deviceReady if I am in a phonegap container, right? – Alexander Feb 18 '15 at 15:27
  • Yes, unfortunately. But there's another thread on SO that has some ideas for you: http://stackoverflow.com/questions/8068052/phonegap-detect-if-running-on-desktop-browser – geekonaut Feb 18 '15 at 15:31