1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    7
    Vote Rating
    0
    socky is on a distinguished road

      0  

    Default 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:

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

    Code:
    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:

    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
    Even though the loader has been disabled:
    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

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,329
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

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

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    7
    Vote Rating
    0
    socky is on a distinguished road

      0  

    Default


    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...

  4. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    7
    Vote Rating
    0
    socky is on a distinguished road

      0  

    Default


    This issue seems to have been fixed in 2.1.1

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    2
    Vote Rating
    0
    bensnider is on a distinguished road

      0  

    Default 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());
            }
        }
    ...

Thread Participants: 2