How can i check the connection off/on using ionic

with what i can replace " Network.connection"? it’s no more valid !! please i need help

import { Network } from '@ionic-native/network';

 isOnline(): boolean {
     if(this.onDevice && Network){
     return Network.connection!== Connection.NONE;
    } else {
      return navigator.onLine; 

As show in the documentation. You can subscribe to


could you write an example please ! ?

Would be the simplest way, but unfortunately I dont think the function works properly, onConnect, onDisconnect and onchange are not triggering?

There were some old similar problems on github like this.

Can someone else try it?

1 Like

Apologies if this is too silly, but you will see that exact behavior if you install the native shim but forget to actually install the underlying cordova plugin.


Not silly at all, Im pretty sure I installed the plugin, Ill check it when I get to the office. But when I try to get the property it returns the type of connection properly. It just doesnt give the on change event.


Checked, and you were indeed right! It seems that I forgot to include the network plugin. Would have never guessed it. As per usual, thanks alot @rapropos!


You can check the following => {
this.status = ‘network was disconnected :-(’;
this.presentToast(‘network was disconnected!’);
}); => {
this.status = ‘network was Connectedd :-(’;
this.presentToast(‘network was Connectedd!’);

  if( !== 'none'){
    return true;
  }else if( === 'none'){
    this.presentToast('Please Check your network and try again');
    this.presentToast('Please Check your network and try again');

Here you check Internet connection 100% working on all devices.

Try in simple way :

  document.addEventListener("online", ()=>{
    console.log("Internet available"); 
  }, false);

  document.addEventListener("offline", ()=>{
    console.log("No internet available"); 
  }, false);