iphone - 我们如何检查被用户或 iOS 杀死的 ios 应用程序

标签 iphone ios background-process

<分区>

如果应用程序在后台完成约 10 分钟,它将处于挂起模式。 App可以通过以下两种方式被杀死:

  1. iOS 可以终止应用程序:在这种情况下,“applicationWillTerminate”将调用。

  2. 用户可以使用多任务 UI 明确终止应用程序。(通过双击主页按钮并按下 -(红色)按钮)

在第二种情况下,我们如何才能让该应用程序被用户杀死?

我检查了下面的问题,但没有结果: App killed by user

最佳答案

如果您的应用程序处于挂起状态,那么无论是谁终止了应用程序 iOS 或用户,都不会调用 applicationWillTerminate

您的 applicationWillTerminate 只会在您的应用程序处于后台并且被终止(由 iOS 或用户)时调用,术语后台意味着它在后台运行而不是挂起状态。

刚刚阅读this reference

applicationWillTerminate:—Lets you know that your app is being terminated. This method is not called if your app is suspended.

这是各种状态的表格 enter image description here

Background - The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see Background Execution.

关于iphone - 我们如何检查被用户或 iOS 杀死的 ios 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15525513/

相关文章:

iphone - 为什么这些 "member"变量表现得像静态变量?

iphone - 如何在 iPhone 进入飞行模式时收到通知?

iphone - 如何在 iPhone sdk 中传递 float 数据类型的值?

iphone - MKAnnotationView 不可拖动,尽管我认为它已正确实现?

ios - Swift:比较隐式解包的可选结果为 "unexpectedly found nil while unwrapping an Optional values"

ios - SwiftUI 将 @Published var 从一个 ObservableObject 映射到另一个

asp.net - 如何防止 Hangfire 重复作业在连续执行 30 分钟后重新启动

ios - swiftc 失败,错误代码为 1

ios - 在ios后台重复运行代码

windows-phone-7 - WP7 无效的跨线程访问 - ScheduledTaskAgent