2 Replies
      Latest reply on Feb 28, 2019 7:27 AM by PBK
      MetaImi Level 1 Level 1 (0 points)

        Hi

         

        I have an app designed like fetch changes (from a custom zone based on tokens, CKFetchRecordZoneChangesOperation) , save locally to core data, then upload unsynced local changes. It works fine now, but I realised the next fetch is downloading the uploaded items, which completly makes sense, since the change token is not updated after the upload. My question is how to solve this situation? I did not find a way to get a new zone change token from the CKModifyRecordsOperation. Obviously I can't discard the next update completly becuase there might be other items from other device.

         

        Thanks

        • Re: Fetch after create
          digitalglen Level 1 Level 1 (10 points)

          Cache as you go and associate the data with the recordID, and, having received a notification that something's changed, check your cache first to determine whether you already have that data, and post a request only if you do not.

          • Re: Fetch after create
            PBK Level 7 Level 7 (3,145 points)

            You can immediately do another CKFetch RecordZoneChangesOperation, ignore (your recent) changes, and retrieve the new change token /para/ or you can store the last change token (the one just before the current change token) in the data itself and use that as the ‘real’ change token.