I have installed Network library too but If i disable or enable my local network connection not show any response on my console window.
Below is the app.componant file below i have write the code whats wrong with my coding please let me know, Help me to resolved these issue…
Thank you in advance!
import { Component } from ‘@angular/core’;
import { Platform, Events } from ‘ionic-angular’;
import { StatusBar } from ‘@ionic-native/status-bar’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;
import { HomePage } from ‘…/pages/home/home’;
import { Network } from ‘@ionic-native/network’;
import { NetworkProvider } from ‘…/providers/network/network’;
@Component({
templateUrl: ‘app.html’
})
export class MyApp {
rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, public events: Events,
public network: Network,
public networkProvider: NetworkProvider) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
this.network.onConnect().subscribe(()=>{
console.log('network connected!');
alert('ok');
});
this.network.onDisconnect().subscribe(() => {
console.log('network was disconnected :-(');
alert('failed');
});
});
}
}