Search code examples
swifttokencloudkit

Can't use serverChangeToken in CKFetchRecordZoneChangesOperation


In recordZoneFetchCompletionBlock I am getting serverChangeToken, and official Apple documentation says about serverChangeToken it returns:

serverChangeToken The current server change token to be stored and used in subsequent CKFetchRecordZoneChangesOperation instances.

But there is no any token property in CKFetchRecordZoneChangesOperation, no such parameter in its constructor. How can I pass serverChangeToken into the CKFetchRecordZoneChangesOperation?


Solution

  • Create an instance of ZoneConfiguration and assign the saved token to previousServerChangeToken

    let options = CKFetchRecordZoneChangesOperation.ZoneConfiguration()
    options.previousServerChangeToken = zoneChangeToken
    

    and pass the options in the configurationsByRecordZoneID parameter

    zoneChangeToken represents the current server change token to be stored