CKModifyRecordsOperation, get change token afterwards

After doing a CKModifyRecordsOperation, what's the suggested way to get the current change token? Since in most cases*, pushing changes won't cause a notification kickback and when there is a trigger to fetch changes, the record will just sync to match the current store data so nbd, but since I'm in an open operation I'd also like to fetch the changeToken from the completed operation to prevent that reduntant occurance.


The documentation on clientChangeTokenData gives a hint: When you modify records from a fetch operation, specify a client-generated data token using this property to indicate which version of the record you last modified. Compare the data token you supplied to the data token in the next record fetch to confirm the server has successfully received the device’s last modify request.


... but I'm having a hard time visualizing this process for what I'm specifically looking to do. Do you think after writing, I do a (in this case) database change fetch to get the up to date token? If so and ignoring changes from that fetch, is there a way I can pin the history to ensure the token I'm getting isn't one containing changes that originated outside of the app (in the case of multiple users editing concurrently).


Kind of a weird question, but any insight would be much appreciated!

Accepted Reply

>After doing a CKModifyRecordsOperation, what's the suggested way to get the current change token? Since in most cases*, pushing changes won't cause a notification kickback and when there is a trigger to fetch change


If I remember correctly, I believe Apple recommends you don't. Whatever change token you have will be behind the current server change token, and later you will get the changes that the current device sent. I believe in one of the WWDC videos they say to just process them to make sure you are in sync with the server.

Replies

>After doing a CKModifyRecordsOperation, what's the suggested way to get the current change token? Since in most cases*, pushing changes won't cause a notification kickback and when there is a trigger to fetch change


If I remember correctly, I believe Apple recommends you don't. Whatever change token you have will be behind the current server change token, and later you will get the changes that the current device sent. I believe in one of the WWDC videos they say to just process them to make sure you are in sync with the server.

Sounds good to me! Thanks!