Hi All,
I am using Ionic2 rc4, and want to check the network connection. Following this documentation and this documentation, I install the plugins:
$ ionic plugin add cordova-plugin-network-information $ npm install --save @ionic-native/network
code
platform.ready().then(() => {
...checkNetwork()();
});
public checkNetwork(): void {
document.addEventListener("offline", this.offline, false);
document.addEventListener("online", this.online, false);
Network.onConnect().subscribe(()=> {
console.log('Network.type = ', Network.connection, Network.name);
this.online();
});
}
offline() {
alert('offline');
}
online() {
alert('online');
}
The offline()
and online()
functions, never get ionvoked.