简体   繁体   English

通过从最近的活动栏中滑动杀死离子应​​用中的应用程序时如何处理代码

[英]How to handle code when app in ionic is killed by swiping from recent activity bar

I made a hybrid app using in ionic v1 in which I have login functionality and I am storing the user data in jstorage ie user id and password but whenever user swipes the app from the recent activity bar in Android, it remains on the same view on which it was before killing the app. 我在ionic v1中使用了混合应用程序,该应用程序具有登录功能,并且将用户数据存储在jstorage中,即用户ID和密码,但是每当用户从Android中最近的活动栏中滑动该应用程序时,它始终保持在相同的视图上在终止该应用程序之前。 I want to logout the user when i swipe or kill the app 我要在滑动或杀死应用程序时注销用户

You can listen to pause or resume events and logout on one of them. 您可以收听暂停或继续的事件并注销其中之一。

 document.addEventListener("pause", onPause, false); function onPause() { // Handle the pause event } 

or 要么

 document.addEventListener("resume", onResume, false); function onResume() { // Handle the resume event } 

Was trying some methods to log out a user when I used the following code and it worked for me. 当我使用以下代码时,正在尝试一些方法注销用户,并且对我有用。

  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); 

And also write this listener inside a device ready 并在准备好的设备中编写此侦听器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过在最近的应用列表中滑动来杀死应用时,Ionic Cordova检测到应用终止事件 - Ionic Cordova Detect app kill event when app is killed by swiping it from the recent app list 在android中通过滑动杀死应用程序时如何处理正在运行的服务? - How to handle running service when app is killed by swiping in android? 当通过在android中刷卡杀死应用程序时,如何执行代码? - How to execute code when app is killed by swiping in android? 通过滑动杀死App时的回调 - Callback when App is killed by swiping 从最近的屏幕刷过应用程序后的活动生命周期 - Activity life cycle after swiping the app from recent screen 从最近的应用程序列表中滑动活动状态后还能保留活动状态吗? - Preserve activity state after swiping it from recent app list? 当通过在Android中刷卡杀死应用程序时,如何调用Web服务(Http请求)? - How to call webservice (Http Request) when app is killed by swiping in android? Android - 从最近的应用程序中滑动应用程序时停止服务 - Android - Service stops when swiping app from recent apps 即使应用程序被杀死,我怎样才能让我的应用程序运行? 从最近的应用程序中删除时在某种意义上被杀死 - How can i make my app run even when app is killed? killed in the sense when it is removed from recent apps 从最近的应用程序中删除应用程序时,“前台”服务将被终止 - “foreground” service is killed when App is removed from recent apps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM