You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/12/22 22:36:48 UTC
[GitHub] PieterVanPoyer commented on issue #79: Online event not firing on
iOS or Android
PieterVanPoyer commented on issue #79: Online event not firing on iOS or Android
URL: https://github.com/apache/cordova-plugin-network-information/issues/79#issuecomment-449601756
Hey, I've tested it on Android.
If you run an Ionic app, the 'online' event is normally added after the deviceready (platform.ready()) event. The 'online' or 'offline' event is already fired then. (The first events are fired even before the first deviceready event on android);
You could always read the type of navigator.connection when you need to:
```
const networkState = navigator.connection.type;
if (networkState === 'none') {
console.log('We're offline')
} else {
console.log('We're online')
}
```
In our company, we allways check the navigator.connection.type before every api call.
If you need more help attach your project.
Kind regards,
Pieter
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org