通过从最近的活动栏中轻扫来杀死Ionic中的应用程序时如何处理代码

时间:2019-02-05 13:50:37

标签: android cordova ionic-framework hybrid-mobile-app

我在ionic v1中使用了混合应用程序,该应用程序具有登录功能,并且将用户数据存储在jstorage中,即用户ID和密码,但是每当用户从Android的近期活动栏中滑动该应用程序时,它都会保留在终止应用程序之前的视图。滑动或杀死应用程序时,我想注销用户

2 个答案:

答案 0 :(得分:0)

您可以收听暂停或继续events并注销其中之一。

document.addEventListener("pause", onPause, false);

function onPause() {
// Handle the pause event
}

document.addEventListener("resume", onResume, false);

function onResume() {
    // Handle the resume event
}

答案 1 :(得分:0)

当我使用以下代码并且对我有用时,正在尝试一些方法来注销用户。

  document.addEventListener("destory", function destoryCallback(){
      apiService.logout().then(function (callback){
        if(callback.data.data)
        {

        }   
        else{

        }     
      }).catch(function (reason) {
        // catch the reason for the failier of api   
    })
    }, false); 

还要在设备就绪的状态下编写此侦听器

相关问题