Reputation: 1
I am building a mobile application using App Framework and Jquery. It is expected to work on Android and IOS.
I would like to alert the user with an alert message when they are not connected to the internet via WiFi or Mobile data. What is the best and accurate way to do it ?
Upvotes: 0
Views: 2311
Reputation: 136
document.addEventListener("intel.xdk.device.connection.update",function()
{
alert(intel.xdk.device.connection);
},false);
intel.xdk.device.updateConnection();
Plz consult the referrend links that will provide you good idea about the connection events.
https://software.intel.com/en-us/node/493063 https://software.intel.com/en-us/node/493102
Upvotes: 0
Reputation: 12952
If you are building hybrid app then you can use the Cordova connection api to detect which type of connection the device is on: http://cordova.apache.org/docs/en/3.0.0/cordova_connection_connection.md.html#Connection
Upvotes: 0
Reputation: 4159
call this in your javascript:
window.navigator.onLine
this will return true if you're connected and false if not.
Upvotes: 1