I want to exit the app when the device have no internet connection, but I use exitApp it nothing happened, here is my code:
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private alertCtrl: AlertController, private network: Network, public deeplinks: Deeplinks, public events: Events) {
platform.ready().then(() => {
let disconnectSub = this.network.onDisconnect().subscribe(() => {
console.log('you are offline');
});
let connectSub = this.network.onConnect().subscribe(()=> {
console.log('you are online');
});
if(this.network.type === 'none' || this.network.type === 'unknown') {
let alert = this.alertCtrl.create({
title: "Internet Connection Problem",
subTitle:"Please Check Your Network connection",
buttons: [{
text: 'Ok',
handler: () => {
platform.exitApp();
}
}]
});
alert.present();
}
});
}
Anyone have experience before? Thanks.