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/26 09:34:50 UTC

[GitHub] PieterVanPoyer edited a comment on issue #79: Online event not firing on iOS or Android

PieterVanPoyer edited a comment 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 are offline');
   } else {
      console.log('We are 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