iOS后台获取 [英] iOS background fetch

查看:472
本文介绍了iOS后台获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm little bit confused with background fetch. I read in Apple Developer documentation that fetch happens when OS decides that it should, user can't control background fetch, while on Apple Developer forum post by Apple employee says that if user kills app (double tap on home and button swipe up) background fetch wont happen, in that case user can control background fetch. So can someone please clarify to me if user kills the app with task manager will background fetch still continue in the background or it's killed at the same time as app.

Apple文档:

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

推荐答案

来自doc doc链接:

From the doc you link:


当一个好机会出现时,系统将应用程序唤醒或启动到后台并调用app delegate的应用程序:performFetchWithCompletionHandler:method 。

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

所以,似乎系统是abl e在后台启动一个未运行的应用程序,以便执行后台提取。另一方面,在文档的后面你可以阅读:

So, it seems that the system is able to launch in the background an app that is not running so it executes a background fetch. On the other hand, though, later in the document you can read:


在大多数情况下,系统不会重新启动应用程序强制退出用户。一个例外是位置应用程序,在iOS 8及更高版本中,在用户强制退出后重新启动。但是,在其他情况下,用户必须明确启动应用程序或重启设备,然后系统才能自动将应用程序启动到后台。

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的工程师是对的:强行退出应用程序将其置于一种特殊情况下,不再允许后台提取。

So, Apple's engineer is right: force quitting an app puts it into a sort of special case where background fetches are not allowed anymore.

这篇关于iOS后台获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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