Is there only one CKServerChangeToken or one per Zone?

Hi,


I am currenlty trying to implement the CloudKit Subscribtion stuff. I am not sure about the whole CKServerChangeToken. Is there only one changeToken per Database (private, shared). Or are there many changeTokens (for every CKZone) which I have to store separately?


Have a nice day

Patrick

Replies

It's not clear why you need a CKServerChangeToken to implement CKSubscriptions.


There is one token for each zone - it changes to a new 'value' each time any record in that zone is changed.

Thanks for your answer. Your are right I don't need a CKServerChangeToken to implement CKSubscriptions. But if I get a notification that something changed from a CKDatabaseSubscription. I have to fetch the changes via CKFetchDatabaseChangesOperation and CKFetchRecordZoneChangesOperation therefore I have to use the CKServerChangeToken.


Or do I understand something wrong?

You can also see the CKServerChangeToken of each zone in CloudKit Dashboard > Zones > List Zones

I was never able to use the change token but found a very simple work-around. I keep a 'timestamp' in the app of the last time I queried the database. Each time I query the database I look for records with a later creationDate or modificationDate then the last 'timestamp'. I download those records and advance my 'timestamp' to the latest creationDate or modificationDate. It works like a charm.