-
6 Feb 2013 1:25 PM #1
Error loading app with IOS homescreen launcher and in phonegap
Error loading app with IOS homescreen launcher and in phonegap
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:
or also:Code:TypeError: 'undefined' is not an object (evaluating 'a.online')
event if I don't see a reference to cordova anywhere...Code:index.html:1ReferenceError: Can't find variable: cordova
And to add a little bit weirdness into the mix the loader want's to load a resource:
Even though the loader has been disabled:Code: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
Code: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
Cya
-
8 Feb 2013 8:23 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
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?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
14 Feb 2013 12:40 AM #3
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 #4
-
9 Apr 2013 12:08 PM #5
A Solution
A Solution
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:
Code:... onConnectionChange: function(e) { if (e && typeof e === 'object' && e.hasOwnProperty('online') && e.hasOwnProperty('type')) { this.setOnline(Boolean(e.online)); this.setType(this[e.type]); this.fireEvent('onlinechange', this.getOnline(), this.getType()); } } ...


Reply With Quote