View Full Version : Error loading app with IOS homescreen launcher and in phonegap

6 Feb 2013, 1:25 PM
This is kind of weird behaviour and it's driving me nuts.

I have an app which works most of the time. The app is a normal mobile web app developed with sencha touch 2.1.0. When accessed normally with safari or chrome from iphone/ipad/android/desktop everything works as excepted.

But on IOS when starting the app through an homescreen launcher or when packaging in an phonegap container (without actually using phonegap on the javascript side only for packaging...) the app behaves strangely and doesn't work on some systems. I get the following error for exemple:

TypeError: 'undefined' is not an object (evaluating 'a.online')

or also:

index.html:1ReferenceError: Can't find variable: cordova

event if I don't see a reference to cordova anywhere...
And to add a little bit weirdness into the mix the loader want's to load a resource:

Error: [Ext.Loader] Failed loading 'https://myawesome.mega.site.com/mobile_debug/lib/touch2.1.0/src/picker/Picker.js', please verify that the file exists

Even though the loader has been disabled:

Ext.Loader.setConfig({ enabled: false });

I don't see why this is happening, the app works normally otherwise. It's quite hard to debug this so I still don't have much to offer (but I'm on it...).
While searching through the forum, I come to believe that sencha touch is thinking it is running on an webview with phonegap even though it's not true. It is a webview, but there is no phonegap/cordova.
So is there a way I can tweak this? Or anyone else experienced this same behaviour?

Thanks in a lot

8 Feb 2013, 8:23 AM
When packaged you shouldn't expect the loader to load files so you need to require all the classes and have them built into one. Sencha Touch can detect when it is within phonegap so that may be why you see cordova error, are you loading the JS file for it?

14 Feb 2013, 12:40 AM
You're right phonegap is detected, but I'm not using phonegap in the application thus I don't include the JS file. In one scenario described above, I add a shortcut of the webpage to the homescreen in ios, and this causes the page to be opened in a webview. I guess it's here where sencha touch get's confused as it concludes webview == phonegap.

I will check if I can force sencha touch to behave like in a normal browser...

21 Feb 2013, 4:45 AM
This issue seems to have been fixed in 2.1.1

9 Apr 2013, 12:08 PM
I had this problem in 2.1.1 as well. I tracked it down to an event object being undefined in some cases (not every app launch would fail...) early in the launch process. I just monkey patched the Ext.device.connection.Sencha class to check if the event object is defined before attempting to access its properties.

I have patched the class file with the following:

onConnectionChange: function(e) {
if (e && typeof e === 'object' && e.hasOwnProperty('online') && e.hasOwnProperty('type')) {

this.fireEvent('onlinechange', this.getOnline(), this.getType());