iOS后台获取

标签 ios background-fetch

我对后台获取有点困惑。我在 Apple Developer 文档中读到,当操作系统决定它应该执行时,用户无法控制后台获取,而在 Apple Developer 论坛上,Apple 员工的帖子说,如果用户终止应用程序(双击主页并向上滑动按钮)背景获取不会发生,在这种情况下用户可以控制后台获取。如果用户使用任务管理器终止应用程序,那么有人可以向我澄清一下,后台获取是否仍会在后台继续,或者它与应用程序同时被终止。

Apple 文档:

https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH4-SW1

最佳答案

从您链接的文档:

When a good opportunity arises, the system wakes or launches your app into the background and calls the app delegate’s application:performFetchWithCompletionHandler: method.

因此,系统似乎能够在后台启动一个未运行的应用程序,因此它会执行后台获取。但另一方面,您可以在文档的后面阅读:

In most cases, the system does not relaunch apps after they are force quit by the user. One exception is location apps, which in iOS 8 and later are relaunched after being force quit by the user. In other cases, though, the user must launch the app explicitly or reboot the device before the app can be launched automatically into the background by the system.

因此,Apple 的工程师是对的:强制退出应用会将其置于一种特殊情况下,不再允许后台提取。

关于iOS后台获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27877335/

相关文章:

android - 手机间隙 : local notification repeat every Sunday of the week?

ios - 将数据发送到服务器/在后台重试请求的选项

ios - 警告 : Application delegate received call to -application:performFetchWithCompletionHandler: but the completion handler was never called

ios - 后台任务执行未按预期进行

ios - 什么是 SAObjects.framework?

ios - 谷歌地图 iOS MapView

ios - 如何跳过传入 [NSString stringWithFormat :] 的数据

ios - 在使用 LargeTitle 和带有 TableView 的分段控件时遇到问题

ios - 后台获取和本地通知

ios - 突然出现许多 Fabric Out of Memory session : Can Fabric OOM Reports ever be false alarms?