I'm trying to execute a method when the user leaves the app. I tried everything:
ionViewWillUnload() {
console.log("Wlill unload");
this.leaveRoom();
}
onDestroy() {
console.log("DESTROY");
this.leaveRoom();
}
ionViewWillLeave() {
this.leaveRoom();
}
Unfortunetly they are not executed when user closes the app or when the user refresh the page.
Any idea?
Import Platform:
import { Platform } from 'ionic-angular';
Add Platform to the constuctor:
constructor(public navCtrl: NavController, platform: Platform)
subscribe to the platform pause
and resume
:
platform.ready().then(() => {
this.platform.pause.subscribe(() => {
console.log('[INFO] App paused');
});
this.platform.resume.subscribe(() => {
console.log('[INFO] App resumed');
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With