检测应用程序何时在后台状态下被用户杀死 [英] Detect when app killed by user in background state iOS

查看:177
本文介绍了检测应用程序何时在后台状态下被用户杀死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在聊天应用程序中工作,需要显示用户状态(离线/在线)。
当我的应用程序处于前台和后台时,我需要将用户显示为在线(通过VoIP管理)。
但是,当用户终止该应用程序时,它应该脱机。

I am working in a chat application where I need to show user status (offline/online). When my app is in foreground and background then I need to show user as online (managing by VoIP). But when the user kill the app then it should go to offline.

我必须维护一个标志以显示脱机状态,这是我在委托功能中管理的 applicationWillTerminate ,但此功能仅在应用程序处于前台状态且用户通过双击主屏幕按钮并向上滑动将其杀死时调用。
当应用程序处于后台状态时,不会调用此函数。我的意思是只需按一下主页(应用程序将在后台运行),然后再次双击以向上滑动即可。

I have to maintain a flag to show offline which I am managing in delegate function applicationWillTerminate but this function only called when app is in foreground state and user kill it by pressing double tap home button and swipe up. This function does not get called when app is in background state. I mean simply press home by single tap (app will go in background) then again double tap to swipe up.

我有100%获得任何功能的功能吗?调用其中一个应用程序处于后台/前景状态,并且用户杀死该应用程序?

推荐答案


是否有任何功能可以让我100%调用其中一个应用程序处于后台/前景状态,并且用户杀死了该应用程序?

Is there any function where I get 100% call either app is in background/foreground state and user kill the app?

否。恰好相反。如果您的应用已在后台终止,则处于挂起状态(即由于特殊权利而未在后台运行),则可以100%确定不会发生任何事件。你不能。您已被暂停并且未在运行。该应用程序在睡眠中死亡。

No. Just the opposite. If your app is terminated when already in the background, if it is suspended (ie not running in the background due to special entitlement), it is 100% certain you will get no event. You cannot. You are suspended and not running. The app dies in its sleep.

这篇关于检测应用程序何时在后台状态下被用户杀死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆