I am developing a watchOS Complication with type graphicRectangular
. Something like the apple activity or heart rate complication. These updates often and display some graph data.
My graph works – showing calendar events in timeline.
I cannot update it "every minute". That would be nice to set a marker for the actual time (check screenshot) in the timeline graph. But that idea is mostly gone since I can only force to update the timeline 50 times a day (as I have read). Apple just says
If your complication has already exceeded its allotted daily budget for execution time, calls to this method do nothing.
So there is nothing I can do, right? Not even when my goal is not submitting it to the AppStore and getting it reviewed?
Now I have developed a function that checks if the text needs to get updated (in screenshot above 13:00 Lorem Ipsum) or the graph has changed and if so triggering the reloadTimeline()
method. So not just reloading it every time but only when necessary. But how should I call this function? I've tried in background Task but that only check "when it wants" – I also build a repeatable 30 sec Timer in ExtensionDelegate. That also works – but seems only to work when XCode runs the app – If I stop in XCode then the graph nearly gets only updated every 15 minutes or something (background Task maybe).
Also I have included EventKit observer for storeChanged(). So I can reload the graph if something changed in calendar. That also work well and quote fast when running the app with XCode active. Stopping the app and using it on the watch "outside XCode" seems to have a heavy delay – sometimes it do never work.
When opening the app (tap on complication) the storeChanged()
event gets triggered immediately (I think it is this function – I can't really debug that since connected to XCode every works well super fast) and after closing the app the complication is refreshed.
Is there a reason why the storeChanged()
event get triggered super fast then running via XCode but is extremely laggy / slow / only triggering when opening the app when not running via XCode?
Is there a reason why my Timer do not run when not running through XCode? When running with XCode I can see debug prints in console from these timed 30 sec "checks". But these seems nothing to do when running outside XCode. Just rarely updating the complication.
Another example: This morning when I put on my watch the graph from yesterday was still visible. So background Task or Timer did not work over night. When opening the app (tap complication) then the graph get refreshed immediately.
Where is the correct place for the EventKit observer or the Timer?
ExtensionDelegate
or ComplicationController
?