Hi All !
i am working with ionic 2 RC1 and using sublime as text editor. i need to check if the network connection is connected or not. so for this purpose i am using ionic native Network for this purpose. but i am facing problem with the Network.onDisconnect() Observable. I have edited initializeApp()
method in which i check for network connection and show alert if connection got disconnected. the I have the following code written in app.component.ts
showAlert(title, msg) {
let alert = this.alertCtrl.create({
title: title,
subTitle: msg,
buttons: ['OK']
});
alert.present();
}
initializeApp() {
this.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.
let disconnectSubscription = Network.onDisconnect().subscribe(() => {
this.showAlert("Error", "No internet connection");
});
StatusBar.styleDefault();
});
}
The problem i am facing is that alert is shown twice if application get disconnected from internet. I have found similar issue in this post but it got unanswered. Any help on this regard will be much appreciated.
Thanks in advance