How to debug NSPersistentCloudKitContainer background updates?

I have been using NSPersistentCloudKitContainer in my app for a while now.

My main issue at the moment is that even though I have followed all of the documented steps for setting up background silent notifications, they don't seem to be working. (I query for the Core Data state from a Shortcut/Intent and can verify that the Core Data store hasn't been updated.) This hasn't been too much of an issue, but with new system features like widgets (WidgetKit), this is an issue I can no longer ignore.

I'm not sure if it's completely out of my control (e.g. the OS just has decided not to deliver the notifications in the background) or if there's some undocumented step I need to take to ensure it is set up correctly.

Has anyone gotten background syncing to work properly with NSPersistentCloudKitContainer? Did you have to do anything special to get it to work? Any tips for debugging what might be going wrong?

Replies

You can inspect the logs from apsd, dasd, and cloudd to see whether or not a push is being delivered on your topic. It's possible the notification is being deferred but a reproducible case and a sysdiagnose are enough for you to file a radar.

During development you should wait 10-20 minutes for the push before filing a bug and ensure that you're testing against the production push / CloudKit environments.
Hey Ryan, did you find a solution for this?
I am currently experiencing the same issue and didn't come to a solution.

Very frustrating.
I have the same question. I haven't been able to see any source explicitly state that NSPersistentCloudKitContainer sets the app to update its db while it is in the background, so I am starting to doubt it is even possible.
We'll need a sysdiagnose from each of the devices to investigate.
I, too, followed the sample app and documentation and have issues with background syncing. When the app is in the foreground, I can get updates every 10-15 seconds, but when in the background, I never seem to get an update.

This has caused an issue with my app where, when the user launches it and updates data, it's soon overwritten by updates from CloudKit.

I will be working on filing feedback for this over the next week.