Search code examples
ioscloudkitcksubscription

How to update all client records from CloudKit?


My app stores locally all the records that CloudKit stores. So it is not the big data small phone concept, but all data server - all data client concept. I need all the updates from time to time when app launches again.

Should I set up for all existing record type CKSubscription?

  • It might come to much notification from server, even though I guess there is a 'silent mode', there should be a limit on storagecapacity of iCloud notification collection.

Should I delete all local record when app launches and download again from CloudKit to get the updates?

  • Need to update too much data every time.

Solution

  • CloudKit has the CKFetchRecordChangesOperation for this. You can request all changes within a zone since the previous update. You can then synchronize that data with the storage inside your app.

    If you do use subscriptions, then if there are multiple notifications send in a short period, there is a big chancre that your app won't get all notifications. Apple will limit that. This is why after processing received subscription notifications you should also execute a CKFetchNotificationChangesOperation after you received a notification.