At https://developer.apple.com/documentation/clockkit/updating_your_complication there is this information:
If didFinishDownloadingToURL occurs first, and then the handleBackgroundTasks with a WKURLSessionRefreshBackgroundTask occurs second, then we presumably need to call setTaskCompletedWithSnapshot immediately. How do we know that's the right thing to do? Are we supposed to observe timing to understand that these two seperate calls are related? Are we supposed to maintain our own state machine to know that we are about to receive a pair of calls in unknown order? What's the right way to structure our behavior here?
thanks
In example code I've seen online, people usually receive a call to handleBackgroundTasks with a WKURLSessionRefreshBackgroundTask, store that value, then receive a didFinishDownloadingToURL, process the download, and then call setTaskCompletedWithSnapshot with the stored value.Also, there’s no guarantee about the order in which the system calls URLSession:downloadTask:didFinishDownloadingToURL: and handleBackgroundTasks:. Your app must handle all possible cases.
If didFinishDownloadingToURL occurs first, and then the handleBackgroundTasks with a WKURLSessionRefreshBackgroundTask occurs second, then we presumably need to call setTaskCompletedWithSnapshot immediately. How do we know that's the right thing to do? Are we supposed to observe timing to understand that these two seperate calls are related? Are we supposed to maintain our own state machine to know that we are about to receive a pair of calls in unknown order? What's the right way to structure our behavior here?
thanks