Reputation: 11
In phonegap when the event online product I trigger a reload of data but the problem is that the online or offline event fires two times in succession: it is creating a bug!
Here is my code:
document.addEventListener ("deviceready" onDeviceReady, false);
document.addEventListener ("online", onOnline, false);
document.addEventListener ("offline", onOffline, false);
Could you help me
thank you
Upvotes: 1
Views: 447
Reputation: 4742
I would only add online
and offline
event listeners after the device is ready:
document.addEventListener ("deviceready" onDeviceReady, false);
function onDeviceReady() {
document.addEventListener ("online", onOnline, false);
document.addEventListener ("offline", onOffline, false);
}
function onOnline(){
}
function onOffline(){
}
Upvotes: 1
Reputation: 3838
Try by add plugin in this way:
cordova plugin add org.apache.cordova.network-information
For further details refer this link.
Upvotes: 0