How to get NSPersistentCloudKitContainer to sync in background

Is it possible for an app using NSPersistentCloudKitContainer to enable sync in the background, if so, how?

  1. Install app on your iPhone and iPad, create some data, it automatically syncs to both and life is good
  2. Close the iPad app
  3. Modify the data on iPhone

Desired behavior: The backgrounded iPad app should sync (even if it takes a while) and be informed that its local database has finished syncing or similarly that changes were made.

The use case is I want to reload my widget when data changes so it's up-to-date, so I need my app to sync it in the background, then notify when it's complete to be able to trigger the widget reload.

I am concerned it will be a poor widget experience if it's always showing stale data until they manually open the app to initiate sync - kind of defeats the purpose of widgets. ha

According to this post, they found sync is never run in the background. Is this not the case, or has it changed in iOS 15?

Thanks!

Replies

Please file bugs for sync in widgets. WidgetKit / ExtensionKit do not allow NSPersistentCloudKitContainer to sync today outside your application's process.

  • Thanks, though I believe that would not be necessary to achieve this since the app can trigger the widget to reload. What we need is the main iOS app to enable NSPersistentCloudKitContainer to sync in the background right, is that possible?

Add a Comment

Hello, have you found a solution for this? Thank You