I'd like to conditionally reload my active complication in the requestedUpdateDidBegin
function or actually tell ClockKit
to set the next check 15 minutes before the end of the current timeline entry, but how can I do that without knowing what's in the current complication?
Here's what I'm trying to do:
if let complications = CLKComplicationServer.sharedInstance().activeComplications {
for item in complications {
// Get timeline entry and template used?
}
}
For the current complication, I can only get the family, but no other info like timeline date or template used. Is there a way to get this?
The complication server requests data from your complication controller, but it's not designed to provide its timeline data to you. All you can find out from the server are the earliest and latest time travel dates.
You'd have to get timeline details from the original data you used to create the timeline entries in the first place.
As for scheduling your update 15 minutes before the end of the last entry, you can very easily schedule that as part of the previous reload request. The very last thing the complication server requests (after reloading or extending the timeline) is the next update date.
Since the complication server has just asked you for the future timeline entries in getTimelineEntriesForComplication:afterDate:
, you can make note of the last timeline entry's date, offset it by 15 minutes, then return that new date once getNextRequestedUpdateDateWithHandler
momentarily gets called.