facebook

navigator.network.connection.type in iOS

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #341281 Reply

    upasana
    Member

    Hi

    The following function , works properly for android builds, but not for iOS builds. What could be the issue?

    function checkConnection()
    {
        network = navigator.network.connection.type;    
        var states = {};
        states[Connection.UNKNOWN]  = 'Unknown connection';
        states[Connection.ETHERNET] = 'Ethernet connection';
        states[Connection.WIFI]     = 'WiFi connection';
        states[Connection.CELL_2G]  = 'Cell 2G connection';
        states[Connection.CELL_3G]  = 'Cell 3G connection';
        states[Connection.CELL_4G]  = 'Cell 4G connection';
        states[Connection.NONE]     = 'No network connection';
        
        alert('Connection type: ' + states[network]);
    }

    Thanks.

    #341290

    support-michael
    Keymaster

    1) What version of MobiOne are you using?

    2) If you are using MobiOne 2.5M1 what version of Cordova are you using?

    3) What ios device and OS version are you testing?

    4) Are you waiting for the the deviceready callback before using the cordova api?

    #341291

    upasana
    Member

    Hi

    1. I am using MobiOne 2.3.2
    2. No separate cordova.js has been included. In android the built in version worked properly.
    3. ipad version 6.1
    4. yes the checking is done after ondeviceready callback.

    Regards

    Upasana

    #341292

    support-michael
    Keymaster

    Is the ipad support cellular (3G/4G) connectivity or is it only wifi support?

    #341293

    upasana
    Member

    Hi

    Thanks for the reply. It only supports wifi.

    Regards

    Upasana

    #341306

    Hi upasana,

    Can you share more details about what is the problem or error message that you get? does it fail to show alert, shows alert with incorrect message, etc? one or two screenshots would be helpful too.

    #341321

    upasana
    Member

    Hi

    I have attached the source files. The apk is also there that works perfectly on android. But on iOS compilation the same thing does not work.

    Thanks

    Upasana

    Attachments:
    You must be logged in to view attached files.
    #341384

    Have you seen the navigator.network.connection deprecation message ?
    May using navigator.connection It will work.
    Please give me feedback because I’m using the same code but I ca’nt test on IOS
    Thanks,
    Max.

    #341397

    upasana
    Member

    Hi

    I tried out with navigator.connection. Didn’t work on ios.

    Thanks

    Upasana

    #341398

    Please Octavio,
    keep us up to date for this behaviour.
    Thanks,
    Max

    #341466

    Vicky
    Member

    here is the code where it works for an ios. hope this might help…

    
    /**
     * Notification that the UI is about to transition to a new screen.
     * Perform custom prescreen-transition logic here.
     * @param {String} currentScreenId 
     * @param {String} targetScreenId 
     * @returns {boolean} true to continue transtion; false to halt transition
     */
    phoneui.prePageTransition = function(currentScreenId,targetScreenId){
        // add custom pre-transition code here
      // return false to terminate transition
      return true;
    }
    
    /**
     * Notification that the UI has transitioned to a new screen.
     * 
     * @param {String} newScreenId 
     */
    phoneui.postPageTransition = function(newScreenId) {
      
    }
    
    /**
     * Notification that device orientation has changed. 
     * 
     * @param {String} newOrientation 
     */
    phoneui.postOrientationChange = function(newOrientation) {
      
    }
    
    /**
     * Called when document is loaded.
     */
      
    phoneui.documentReadyHandler = function() 
    {
    document.addEventListener("deviceready", onDeviceReady, false);
    }
    function onDeviceReady() {
    checkConnection();
    }
    function checkConnection() {
            var networkState = navigator.connection.type;
            var states = {};
            states[Connection.UNKNOWN]  = 'Unknown connection';
            states[Connection.ETHERNET] = 'Ethernet connection';
            states[Connection.WIFI]     = 'Wi-Fi connection';
            states[Connection.CELL_2G]  = 'Cell 2G connection';
            states[Connection.CELL_3G]  = 'Cell 3G connection';
            states[Connection.CELL_4G]  = 'Cell 4G connection';
            states[Connection.NONE]     = 'No network connection';
     
           phoneui.alert('You are using '+ states[networkState], null, 'Connection Type');
    }
    
    
    #341504

    support-michael
    Keymaster

    Thanks for sharing the example project.

    The navigator.app.loadUrl() is not a cross platform api. It was only implemented on android. See the following info and there are many other references to the same issue:
    http://stackoverflow.com/questions/13803020/navigator-app-undefined

    In the latest MobiOne 2.5 milestone-1 you have access to Cordova/PhoneGap 2.9 which includes the cross platform InAppBrowser api.

    #341505

    support-michael
    Keymaster

    I also successfully retested the navigator.connection api from you example on ipad1/ios4.3(wifi only) and iphone5/ios6.

Viewing 13 posts - 1 through 13 (of 13 total)
Reply To: navigator.network.connection.type in iOS

You must be logged in to post in the forum log in