When WKExtension.scheduleBackgroundRefresh is supposed to call scheduledCompletion handler?

邮差的信 提交于 2019-12-07 21:17:08

问题


I'm trying to schedule background task with such line:

WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: Date(timeIntervalSinceNow: TimeInterval(5) * 60), userInfo: nil, scheduledCompletion: self.scheduledCompletion)

where

func scheduledCompletion(error: Error?) {
        if error == nil { print("successfully scheduled application background refresh") }
        else { print("error scheduling background refresh, error: \(error)") }
}

According to documentation:

scheduledCompletion A block that is called by the system after the background app refresh task has completed.

But by unknown reason it is being called straightly after background refresh task is being scheduled. Background refresh task is being called on correct time, tho, and scheduledCompletion is not being called after that.

So is it an error in documentation, bug in WatchKit or I'm doing something wrong?


回答1:


Despite documentation's description, scheduledCompletion will be when the task will be scheduled. It was mentioned during WWDC16 Keeping Your Watch App Up to Date session at 11:23:



来源:https://stackoverflow.com/questions/41238434/when-wkextension-schedulebackgroundrefresh-is-supposed-to-call-scheduledcompleti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!