How often do I schedule Widget updates?

Classically, the demo in the Meet WidgetKit video used a Calendar as an example, where clearly the times to update are simple to calculate based on when the users events will occur.

I'd like to know about the Activity/Fitness Widget. There's no way to tell when a user will burn that next calorie and as far as I can tell, there's still no background observer in HealthKit you can use to call an update on changes. So, with that in mind, how often should I call to update?

This same dilemma applies to ClockKit and WatchOS complications.
Hello,

After discussing with an Apple Engineer today, he explained that while it is highly recommended to load as few entries and timelines as possible, loading on a minute basis is possible. With that in mind, he suggested that loading more entries in one timeline may be more efficient than loading small timelines. Personally, I am working on a timer-based app and have been able to successfully load the widget's data every minute with ease.

In regards to the fitness app, there are probably a few things going on. The widget probably loads the user's data every hour or so. However, there is an API capability available so that if something were to occur within the actual health app, the app could signal the timeline to reload. This is purely a guess of how Apple would configure the widget, but those methods are available.

Let me know if that information helped and if you have any questions I'd be happy to help discuss it further :)
Thanks for the reply. Yes there is the HKObserverQuery, although I'm not sure how effective this is for background update. I'll investigate implementing that and calling a timeline update every time it returns new data, will report back!
Thanks
Simon,

Did you have any success with HKObserverQuery and reloading the timeline?

I have a workout app that has a "workout" widget. Presently, I have an observer query listening to .workoutType() and I set the background update frequency to .immediate. On iOS 12.2 RC for my iPhone XS, I keep seeing the observer query getting invoked second after second--even though there is no new workout being saved.

Have you experience anything like this where the observer query is getting hammered with updates more than you expect? I'm guessing it is some bug where the HKObserverQuery is getting invoked as if the app was entering foreground, and the widget being on screen is somehow tripping this.

I filed a FB on this unexpected behavior in case anyone at Apple sees this and wants more details. FB8887079
Edorphy,

I'm not sure I can really comment on iOS 12.2, though I suspect Apple will only really investigate bugs with iOS 14 currently....

I've not bothered with a HKObserverQuery in the end as I wasn't able to get it to work reliably. Instead I just use the Widget update callbacks to do fresh HKSampleQueries.

Regards
Simon
How often do I schedule Widget updates?
 
 
Q