Refresh Widget doesn't work from background push notification.

As stated in other posts like:

Even though the recommended way from Apple documentation is to use push notifications to reload widgets timelines calling WidgetCenter.shared.reloadAllTimelines(), it is unreliable and I couldn't find a pattern of why it works 10% of times and not the other 90%.

While the debugger is connected to the App it always works though. My widget needs to reflect updated information otherwise it becomes useless since it display smart home devices states such as the Apple Home widget does as well.

Hi,

For WidgetKit there are a few things to consider:

You get 10MB of space per timeline. You get 72 refreshes per day and an unlimited amount of entries. This means you can create a timeline of size 10MB and refresh every 20 minutes.

The system, or Springboard essentially, will reload if resources are available to do such. None of this is guaranteed. OnAppear isn't really valid for Widgets because they don't explicitly have a lifecycle and UI should be driven by your entry values, not runtime updates when the UI appears. The views themselves are archived and saved as a timeline so even in onAppear things aren't editable.

Lastly, if you think there is an issue with reloading, the best first course of action would be to use Console.app to monitor to the relevant processes related to your app and extensions.

A good way to start would be with filtering by the BundleID of the target and / or the target name itself (the process name). To debug WidgetKit, LiveActivities, Dynamic Island you'll want to monitor springboardd, liveactivitiesd along with other relevant processes.

Refresh Widget doesn't work from background push notification.
 
 
Q