当 ionic 中的应用程序通过从最近的 activity 栏滑动而被杀死时如何处理代码
How to handle code when app in ionic is killed by swiping from recent activity bar
我使用 ionic v1 制作了一个混合应用程序,其中我有登录功能,我将用户数据存储在 jstorage 中,即用户 ID 和密码,但每当用户从最近的 activity 栏中滑动应用程序时Android,它保持在终止应用程序之前的相同视图中。我想在滑动或终止应用程序时注销用户
您可以收听暂停或恢复 events 并在其中之一上注销。
document.addEventListener("pause", onPause, false);
function onPause() {
// Handle the pause event
}
或
document.addEventListener("resume", onResume, false);
function onResume() {
// Handle the resume event
}
当我使用以下代码时尝试了一些注销用户的方法并且它对我有效。
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);
并且还将此侦听器写入设备就绪
我使用 ionic v1 制作了一个混合应用程序,其中我有登录功能,我将用户数据存储在 jstorage 中,即用户 ID 和密码,但每当用户从最近的 activity 栏中滑动应用程序时Android,它保持在终止应用程序之前的相同视图中。我想在滑动或终止应用程序时注销用户
您可以收听暂停或恢复 events 并在其中之一上注销。
document.addEventListener("pause", onPause, false);
function onPause() {
// Handle the pause event
}
或
document.addEventListener("resume", onResume, false);
function onResume() {
// Handle the resume event
}
当我使用以下代码时尝试了一些注销用户的方法并且它对我有效。
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);
并且还将此侦听器写入设备就绪