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?

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


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.