简体   繁体   English

在后台获取上调用完整函数时,何时需要使用“ .noData”?

[英]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.

相关问题 什么时候需要使用CKRecord的encodeSystemFieldsWithCoder? - When would I need to use encodeSystemFieldsWithCoder of CKRecord? 应用程序在后台时调用 function - Calling a function when the application is in background 调用UITableView reloadData方法时是否需要使用@synchronized? - Do I need to use @synchronized when calling UITableView reloadData method? 为什么我会使用无主的自我? - Why would I ever use unowned self? 为什么从前台调用某些东西会崩溃,而从后台调用它却不会? - Why would calling something from the foreground crash, when calling it from the background does not? 什么时候需要使用副本? - when I need use copy? 什么时候课程会有多个指定的初始化程序? - When would a class ever have more than one designated initializer? 在 PubNub 聊天消息 Payload 中发送时,正在接收推送通知,但后台提取未使用 pn_apns 标签调用 - Push Notification is receiving but background fetch not calling with pn_apns tag when sending in PubNub chat message Payload RESTKit没有做什么魔法记录? 我是否需要两个框架? - What does Magical Record do that RESTKit does not do? Would I ever need both frameworks? 当应用程序处于前台和后台时,如何使用Date()函数和时间戳获取经过的时间? - How can I use the Date() function and time stamps from when the app is in the foreground and background to get elapsed time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM