[英]When would I ever need to use “.noData” when calling the complete function on background fetch?
If you have set up a background fetch task to run on iOS, after it completes, you're required to call completionHandler
with one of three options: .newData
, .noData
or .failed
. 如果你已经设置了后台抓取任务iOS上运行,它完成后,你需要调用
completionHandler
有三个选项之一: .newData
, .noData
或.failed
。 Depending on which one you pick and how your tasks succeed, apparently iOS decides how often your app's background fetch is run. 取决于您选择哪一个以及任务如何完成,iOS显然决定了应用程序后台获取的运行频率。
.newData
is the obvious default if everything went fine and .failed
is the obvious fail option, but what about .noData
? .newData
是明显的默认值,如果一切正常,并.failed
是显而易见的失败的选择,但对于.noData
? If iOS penalizes me for attempting to fetch data that is stale, why would I ever want to tell iOS about this? 如果iOS尝试获取过时的数据对我不利,那么我为什么要告诉iOS呢? If this affects the frequency of the background job, wouldn't I be better off just always telling iOS that all data I fetched was new to avoid my app being forced to run background jobs less often than what I defined in
setMinimumBackgroundFetchInterval
? 如果这影响了后台作业的频率,我是否总是告诉iOS我获取的所有数据都是新数据,以免我的应用程序被迫比
setMinimumBackgroundFetchInterval
定义的运行频率更低,这会更好吗?
Depending on which one you pick and how your tasks succeed, apparently iOS decides how often your app's background fetch is run.
取决于您选择哪一个以及任务如何完成,iOS显然决定了应用程序后台获取的运行频率。
That's a false assumption. 这是一个错误的假设。 What is evaluated is the time and energy you use before calling the completion handler.
评估的是您在调用完成处理程序之前使用的时间和精力。 Do not try to game the system;
不要尝试游戏系统; just be quick, efficient, and honest.
只是要快速,高效和诚实。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.