How to sync widgets in background with data in Core Data and CloudKit?

I have an app that shows some data in a widget. When that data is changed on another device, it's supposed to sync to the current device, which works fine.

But the widget doesn't sync until I send the app into foreground (and then the sync happens), which is bad because the widget data should always be up-to-date.

I'm using this Apple guide to sync Core Data and CloudKit with slight modifications.

How can I sync widgets in the background?

Thank you in advance!
I am having the same issue exactly. Did you find a solution?
Widgets cannot run in the background, AFAIK for any purpose, so you'll need to drive this from the application. You probably do not want the widget and the app to BOTH sync from CK. That's twice the work and confusing. Instead, use a group container and the widget can read the same database that the app updated, potentially running with a background task.

If you still have issues, please file a bug report with a sysdiagnose from each of the syncing peers so we can review the system's scheduling of your sync requests.
I've experienced the same issue and also don't have a solution so far.



How to sync widgets in background with data in Core Data and CloudKit?
 
 
Q