recordZoneChangeTokensUpdatedBlock isn't called?

I'm using the new API for iOS 10 described in the 2016 WWDC what's new in CloudKit.


The new CKFetchRecordZoneChangesOperation has a block called recordZoneChangeTokensUpdatedBlock


Which from my understanding is supposed to be called everytime there is a new serverChange token. (possibly multiple times in one operation)


It's meant to be a replacement to the older completion block which had a moreComing flag and left the responsibility to the client to call the operation again.


However, it's not being called at all in my case. (even when the other blocks such as recordWithIDWasDeletedBlock are called meaning that there where changes)



Has anyone found a soultion to this? Thanks.

Accepted Reply

In my tests, it is only called every 200 or so records that changed.

Replies

In my tests, it is only called every 200 or so records that changed.

Ok, I see...


So I suppose it is only called if it the changes exceed the batch limit... I had the impression from the WWDC presentation that it replaced the orignal completion block completely.

Have you ever found a solution or workaround for this? I'm experiencing the same issue: recordZoneChangeTokensUpdatedBlock isn't called (if may or may not be after 200 record changes, but I don't have that many records to begin with). Right now I'm always passing a nil token to CKFetchRecordZoneChangesOperation and download every single record in the zone.


The recordZoneWithIDChangedBlock block of CKFetchDatabaseChangesOperation does get called every time but the token is not interchangable with the tokens used in CKFetchRecordZoneChangesOperation.

Filed radar 29886880

It turns out you need to use recordZoneFetchCompletionBlock instead of fetchRecordZoneChangesCompletionBlock. I missed the first one when reading the documentation. The change token is indeed in the recordZoneFetchCompletionBlock.

operation.recordZoneFetchCompletionBlock = {
               (zoneID: CKRecordZoneID,
               serverChangeToken: CKServerChangeToken?, 
               clientChangeTokenData: Data?, 
               moreComing: Bool, 
               error: Error?) in
// do something with the token??
}


I am running this block and it never gets called! The recordChangedBlock and fetchRecordZoneChangesCompletionBlock all get called, but not the recordZoneFetchCompletionBlock. I'm going crazy here...