Search code examples
iosswiftsynchronizationcloudkit

Force iOS CloudKit synchronization update to download all records to local device


My app maintains a list of files locally on the iPhone. With CloudKit enabled, these files are automatically synchronized to the CloudKit database.

When the application is deleted, all the local data is also deleted. I would like to see if its possible to trigger a CloudKit notification CKNotification, specifically CKQueryNotificationReasonRecordCreated so that all my local records can be resynchronized and redownloaded.

I currently do have a function which which listens to the App delegate's didReceiveRemoteNotification, which then downloads corresponding records. However, to do so, I need to post a "fake" update so that CloudKit post a notification for it to download locally to another device.

I don't want to post a fake update for each record and would like to do a bulk download onto a local device from CloudKit.

Thank you.


Solution

  • I would recommend you just use CKQuery and with a given NSPredicate you will be able to get all the data you need from CloudKit database