When WKExtension.scheduleBackgroundRefresh is supposed to call scheduledCompletion handler?

2.4k views Asked by At

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

There are 1 answers

0
abjurato On BEST ANSWER

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:

enter image description here