我有一个带有 URLSession 代表的课程。我打算将它与后台配置一起使用。我知道当某个事件发生时会调用处理程序,例如didFinishDownloadingTo
.
但是,我的handle
ExtensionDelegate 类确实具有该功能:
func handle( _ handleBackgroundTasks:
Set<WKRefreshBackgroundTask>)
// Sent when the system needs to launch the application in the background
to process tasks. Tasks arrive in a set, so loop through and process each one.
for task in handleBackgroundTasks {
switch task {
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
我想知道:我应该在哪里处理下载后收到的数据?在didFinishDownloadingTo
我的 ExtensionDelegate 类的那个或那个函数上,在 switch 语句的适当情况下?
setTaskCompleted()
同一周期的另一个问题:在完成后台任务后,我到处阅读必须记住的内容。但是我在其他地方读到,如果计划的数据传输尚未完成,则不应将任务设置为已完成。我该如何检查?