- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is this in the XDK, App Preview or a built app? What device/OS?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it's a built app. iPad Air 2 and iOS 8.3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
to me your code returns "Unknown connection" :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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... ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
my iPad is wifi only, so it's really strange that connection.type value is "cellular" and the script above returns "unknown connection" :P
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note the iOS quirks on the readme for that plugin: https://github.com/apache/cordova-plugin-network-information#ios-quirks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know that quirk, but my ipad is wifi only, so it should not care about it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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';

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page