我想知道如何使用“硬件后退”按钮确定何时退出应用程序,并最终清除我的localStorage数据。
我需要这样做的主要原因有三个: 1.询问用户是否真的想退出应用程序2.清除缓存的数据3.迫使用户在应用程序启动时始终登录--因为它是金融应用程序。
谢谢
发布于 2016-10-12 08:48:25
以确定何时退出应用程序。你必须参考此链接
使用registerBackButtonAction()方法来处理handle硬件。
例如:在app.ts文件中
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.
this.platform.registerBackButtonAction(() =>{
// 1. Ask the user if he/she really wants to exit the application
//2. Clear cached data
//3. Force the user to always login anytime the application is started
return;
});
StatusBar.styleDefault();
});
}加油!
https://stackoverflow.com/questions/39993389
复制相似问题