Hi all, I'm trying to solve a very simple problem - I want to get data from the web every hour and then update my complications. That's all.
However, in practice this seems very difficult? I can't find a reliable way to actually update any data. Whether it be `getNextRequestedUpdateDate` not being called or `requestedUpdateDidBegin` not being called after scheduling an update..
I've tried using Background tasks also which have been a bit of a mess to say the least. I opted not to use them because of how bad the API was to implement them.
Has anyone found a worthwhile tutorial or code snippet to actually explain how to do this very simple procedure?
Here is some of my sample code
func requestedUpdateDidBegin() {
print("Starting to update complication")
if ComplicationWebService.sharedInstance.shouldRefresh() {
ComplicationWebService.sharedInstance.getPersonalAgenda() // This gets the data from the web. Upon completion it will call CLKComplicationServer timeline refresh
} else {
ComplicationController.refresh() // This reloads the timelines of the complications using CLKComplicationServer
}
}
func requestedUpdateBudgetExhausted() {
print("Budget exhausted!")
}
func getNextRequestedUpdateDate(handler: @escaping (Date?) -> Void) {
let nextUpdateDate = Date().dateByAddingMinutes(ComplicationWebService.defaultRefreshInterval) // Set to 30 minutes, 10 mins when testing
print("Getting next requested update date: \(nextUpdateDate)")
handler(nextUpdateDate)
}