Page 1 of 1

Online and Offline event not fired when application start

Posted: Thu Feb 23, 2017 10:35 am
by B5107656409

Hello,

how to check internet connection when application start?..
i put alert('I am online') in online event and alert('I am offline') in offline event

but it does not fired when application started ..except I manually set airplane mode on and off.

please help

thanks


Online and Offline event not fired when application start

Posted: Thu Feb 23, 2017 2:55 pm
by Galyna Abramovych

Hello,

To monitor your internet connectivity once the app is started, try using the JS below for that:
code
document.addEventListener("offline", function (){
alert('offline');
}, false);
document.addEventListener("online", function(){
alert('online');
}, false);
/code
Please look at this documentation for more information:
https://cordova.apache.org/docs/en/1....

Also, these links can be useful:
https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...


Online and Offline event not fired when application start

Posted: Fri Feb 24, 2017 6:46 am
by B5107656409

where should I put thouse JS?..
I tried to put them in DeviceReady but it does not triggered..

I tried to set Airplane mode before I start the app.. but "offline" doesnot triggered


Online and Offline event not fired when application start

Posted: Mon Feb 27, 2017 11:30 am
by Serhii Kulibaba

Please check the connection with a "Cordova Network Information" plugin. Here is an example how to use it:
https://cordova.apache.org/docs/en/la...