Reputation: 143
There is a problem with Cordova-plugin-network-information on Android. Even if there is a 4G connection, sometimes, when I resume the app from the background and I check connection with navigator.connection.type it returns connection.type = NONE, but there is an internet connection. If I close and re-open the app it returns connection.type = 4G. I user [email protected] and [email protected]
Upvotes: 2
Views: 1374
Reputation: 30366
This is the workaround I'm currently using for this issue:
document.addEventListener("resume", function(){
navigator.connection.getInfo(function(type){
navigator.connection.type = type;
});
}, false);
See CB-14132 for an explanation of why.
Upvotes: 3
Reputation: 1190
Try to use
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
if(navigator.onLine) {
alert("Internet Connect");
}else {
alert("No Internet");
}
}
Upvotes: 0