当用户离开应用程序时,我试图执行一种方法。我什么都试过了
ionViewWillUnload() {
console.log("Wlill unload");
this.leaveRoom();
}
onDestroy() {
console.log("DESTROY");
this.leaveRoom();
}
ionViewWillLeave() {
this.leaveRoom();
}不幸的是,当用户关闭应用程序或用户刷新页面时,它们不会被执行。
有什么想法吗?
发布于 2016-12-29 12:55:39
import { Platform } from 'ionic-angular';constructor(public navCtrl: NavController, platform: Platform)pause和resume:
Platform.ready().then() => {this.platform.pause.subscribe()) => { console.log('INFO应用暂停“);};this.platform.resume.subscribe(() => { console.log('INFO应用程序恢复”);});};https://stackoverflow.com/questions/41379376
复制相似问题