Are previousServerChangeToken for CKFetchNotificationChangesOperation user specific or database specific?

225 views Asked by At

For public CloudKit databases, does anyone know if the data tokens used for previousServerChangeToken when initializing a CKFetchNotificationChangesOperation are:

1) User specific: a data token can only be used by one Apple ID

or

2) Database specific: the same token can be used by different Apple IDs to specify the same state in the CKNotifications database

I'm wondering because I have some preloaded local data that may need to be updated on first launch, and I'm not sure if I should use CKFetchNotificationChangesOperation (with an initial token saved in the main bundle) or just fetch all the records in the public database and check against the local data.

2

There are 2 answers

0
farktronix On BEST ANSWER

Notification change tokens are a per-user value and they can not be used to assume anything about the state of records in the public database.

It sounds like you're trying to use the public database to store files that update the default files in your application's bundle.

One way to do this would be to store a version property on all of your records of this type. When an app checks to see if it needs any updates it can run a CKQuery for all records with a higher version than what is saved locally. Your app can then download all of those records and use them instead of the data stored in its bundle.

0
Joel On

What you need is CKFetchRecordChangesOperation, but this only works for non-default zones in the user private cloudkit database. This operation will give you all the changes over the record zone, records deleted and updates (with only the changed attributes).