Unable to reload widget timeline from App Intent on physical devices

In my app, there's a widget that should change to one color when clicked and then to another color after 10 seconds.

When I click the widget button (linked to the App Intent), the widget should refresh. When I debug, this happens as expected.

However, if I call WidgetCenter.shared.reloadAllTimelines() in the perform() method of AppIntent, the widget timeline doesn't refresh right away. This issue only happens on real devices and isn't always consistent. In the simulator, the widget refreshes as expected.

Answered by jcgoforth in 780310022

What you are trying to do is not possible and not how the mentioned methods are intended to work.

when you interact with a widget, your app intent will be called and when that intent finishes the perform method your widget will get one guaranteed reload that will happen immediately. There is no way for it to update the widget multiple times. note That even that one update only applies to the widget that was interacted with. If you have multiple widgets, they may or may not get updated automatically.

Calls to reloadAllTimelines is always a suggestion to the system and should never be expected to immediately refresh the widgets. Apple has never really documented what the algorithm is here, but things like how often you are refreshing the widget, how often the user is using your app, and the systems battery power seem to play a role in that decision.

Accepted Answer

What you are trying to do is not possible and not how the mentioned methods are intended to work.

when you interact with a widget, your app intent will be called and when that intent finishes the perform method your widget will get one guaranteed reload that will happen immediately. There is no way for it to update the widget multiple times. note That even that one update only applies to the widget that was interacted with. If you have multiple widgets, they may or may not get updated automatically.

Calls to reloadAllTimelines is always a suggestion to the system and should never be expected to immediately refresh the widgets. Apple has never really documented what the algorithm is here, but things like how often you are refreshing the widget, how often the user is using your app, and the systems battery power seem to play a role in that decision.

Unable to reload widget timeline from App Intent on physical devices
 
 
Q