Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

iOS bad connection.type

Giorgio_B_1
Beginner
1,162 Views

Good morning,

when i use the Network Information plugin and the device is connected to my WIFI the connection.type value is "cellular". How can i fix this?

Tried on XDK 1621 + cordova 3.5 and XDK 1995 + cordova 4.1.3 with the suggested XDK version of the plugin (i used the "reset versions" link in the project page)

Thanks

0 Kudos
9 Replies
John_H_Intel2
Employee
1,162 Views

Is this in the XDK, App Preview or a built app? What device/OS?

0 Kudos
Giorgio_B_1
Beginner
1,162 Views

it's a built app. iPad Air 2 and iOS 8.3

0 Kudos
John_H_Intel2
Employee
1,162 Views

I just tested this on a iphone 6, ios 8.3 and it worked correctly. Make sure to pick the cordova connection plugin :)

 

<!DOCTYPE HTML>
<html>
    
<head>
    <meta charset="UTF-8">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />

    <meta name="format-detection" content="telephone=no">
    <title></title>
    <script src="intelxdk.js"></script>
    
    <script src="cordova.js"></script>
    
    
    

    <script type="text/javascript" language="javascript">
    
    function onDeviceReady()
    {
        var divStatus = document.getElementById("divStatus");
            divStatus.innerHTML = divStatus.innerHTML + "Ready<br>";        
        //intel.xdk.device.hideSplashScreen();                
    }
    
    //initial event handler to detect when intel.xdk is ready to roll
    document.addEventListener("intel.xdk.device.ready",onDeviceReady,false);     
    
    function checkConnection() {
        var networkState = navigator.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.CELL]     = 'Cell generic connection';
        states[Connection.NONE]     = 'No network connection';

        //console.log('Connection type: ' + states[networkState]);
        divStatus.innerHTML = divStatus.innerHTML + states[networkState];
    }

    </script> 
</head>
       
<body bgcolor="#ff0055">
<div id="divStatus" style="border:1px solid red;height:100px; width: 400px; wrap=hard"></div>
    
    <div>
        <button id="showConnection" ontouchstart="checkConnection();">update connection</button>
    </div>    

    
    </body>
</html>

 

 

 

 

 

 

 

0 Kudos
Giorgio_B_1
Beginner
1,162 Views

to me your code returns "Unknown connection" :(

0 Kudos
John_H_Intel2
Employee
1,162 Views

What about if you are connected to wifi? Does it return correctly?

What cell service are you connected to? 

Where are you located?

I assume your ipad air has a cell data plan?

I have an air that is on 7.1 that has a data plan that I will try it on and then maybe upgrade and try it again. But of course its dead now... ;)

0 Kudos
Giorgio_B_1
Beginner
1,162 Views

my iPad is wifi only, so it's really strange that connection.type value is "cellular" and the script above returns "unknown connection" :P

0 Kudos
PaulF_IntelCorp
Employee
1,162 Views

Note the iOS quirks on the readme for that plugin: https://github.com/apache/cordova-plugin-network-information#ios-quirks

0 Kudos
Giorgio_B_1
Beginner
1,162 Views

I know that quirk, but my ipad is wifi only, so it should not care about it.

0 Kudos
John_H_Intel2
Employee
1,162 Views

Well, I updated the ipad air to 8.3 and ran the app (code above) and it returns correctly based on the code above.

 

        states[Connection.WIFI]     = 'WiFi connection';

 

0 Kudos
Reply