[英]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.