首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用localStorage退出应用程序时如何清除ionic2

使用localStorage退出应用程序时如何清除ionic2
EN

Stack Overflow用户
提问于 2016-10-12 07:57:20
回答 1查看 1.1K关注 0票数 0

我想知道如何使用“硬件后退”按钮确定何时退出应用程序,并最终清除我的localStorage数据。

我需要这样做的主要原因有三个: 1.询问用户是否真的想退出应用程序2.清除缓存的数据3.迫使用户在应用程序启动时始终登录--因为它是金融应用程序。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-12 08:48:25

以确定何时退出应用程序。你必须参考此链接

使用registerBackButtonAction()方法来处理handle硬件。

例如:在app.ts文件中

代码语言:javascript
复制
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();
});
}

加油!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39993389

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档