Network events not working

Hi,

On Ionic 4, the events are never fired,

@ionic-native/core”: “^5.9.0”,
@ionic-native/network”: “^5.9.0”,
“cordova-plugin-network-information”: “^2.0.2”,

this.network.onDisconnect().subscribe(() => {
  console.log('network was disconnected :-(');
});

this.network.onConnect().subscribe(() => {
  console.log('network connected!');
  // We just got a connection but we need to wait briefly
   // before we determine the connection type. Might need to wait.
  // prior to doing any api requests as well.
  setTimeout(() => {
    if (this.network.type === 'wifi') {
      console.log('we got a wifi connection, woohoo!');
    }
  }, 3000);
});

Even i felt network events are not firing,
Just console the this.network.type you will get to know which are all the types will come…

I have used network events in ionic 4 app with the same way its firing in actual device.

When in ionic 3 type is cell_4g but in ionic 4 type is coming as just 4g

In the browser, event is not firing

Using the above packages I get nothing.

In my case below versions i having it

@ionic-native/network”: “^5.8.0”,
“cordova-plugin-network-information”: “2.0.1”,

Can you tell how you are testing in browser or real device ??

real device,

Galaxy S10 and a One Plus.

replace console.log with alert.

Have you Imported Network in app.module and added in provider?

And also call this function inside platform.ready in app.component

initializeApp() {
this.platform.ready().then(() => {
  this.statusBar.styleDefault();
  this.splashScreen.hide();
  const connectSubscription = this.network.onConnect().subscribe(() => {
  console.log('network connected!');
  // We just got a connection but we need to wait briefly
  // before we determine the connection type. Might need to wait.
  // prior to doing any api requests as well.
  console.log(this.network.type);
  setTimeout(() => {
    console.log(this.network.type);
    if (this.network.type === 'wifi' ||
      this.network.type === '4g' 
    ) {
      console.log('we got a connection, woohoo!');
    }
  }, 2500);
});
    
});
}

Yes mate, done that.

Nobody else facing this issue?

Same issue. The Network events are not beeing triggered.
Provided Network in AppModule
@ionic-native/network”: “^5.11.0”,
“cordova-plugin-network-information”: “^2.0.2”,
“cordova-plugin-network-information”: {}

first cordova network plugin add providers ,in app.modules

paste the app.components.ts
constructor{public alertController:AlertController,
private network: Network}
this.network.onDisconnect().subscribe(async() => {

  const alert = await this.alertController.create({
          header: 'Data or Wifi',
          message: 'Check Your Connection?',
          buttons:  ['OK']
          
        });
  
        await alert.present();

  });

and check it

and check it