Search code examples
ioscordovaextjssencha-touch-2sencha-touch-2.1

Internet check is failure in Iphone


In my sencha touch application i am unable to retrieve internet connection, but device able to access the wifi when i try to surf through browser. In android its working fine, but in ios the connection is undefined. I am using same wifi for both devices.

 checkConnection: function() {
        if (Ext.os.is('android') || Ext.os.is('iphone')) {
            alert("connection"+Ext.device.Connection.isOnline());
            alert('Your connection type is: ' + Ext.device.Connection.getType());
            return Ext.device.Connection.isOnline();
        }

Solution

  • Are you using phonegap/cordova? If so then why don't you use the cordova network API directly? I.e. try something like

    checkConnection: function() {
        if (Ext.device) {
            return Ext.device.Connection.isOnline();
        } else {
            return navigator.network.connection.type != Connection.NONE;
        }
        return false;
    }