2017-09-09 1 views
0

Swift 3.1, Xcode 8.3.3Wolkenjunge Fehler: Ändern Token abgelaufen ist, benötigt Zurücksetzen

Ich halte einen Fehler von Wolkenjungen bekommen, und ich weiß nicht, was dagegen zu tun.

ich Benachrichtigungen von Wolkenjunge wie das Tracking:

let operation = CKFetchNotificationChangesOperation(previousServerChangeToken: previousChangeToken) 

//Hold the notification IDs we processed so we can tell CloudKit to never send them to us again 
var notificationIDs = [CKNotificationID]() 

operation.notificationChangedBlock = { [weak self] notification in 
    guard let notification = notification as? CKQueryNotification else { return } 
    if let id = notification.notificationID { 
    notificationIDs.append(id) 
    } 
} 

operation.fetchNotificationChangesCompletionBlock = { [weak self] newToken, error in 
    if let error = error{ 
    print(error) //<-- <!> This is the error <!> 
    }else{ 
    self?.previousChangeToken = newToken 

    //All records are in, now save the data locally 
    let fetchOperation = CKFetchRecordsOperation(recordIDs: recordIDs) 

    fetchOperation.fetchRecordsCompletionBlock = { [weak self] records, error in 
     if let e = error { 
     print("fetchRecordsCompletionBlock Error fetching: \(e)") 
     } 
     //Save records to local persistence... 
    } 

    self?.privateDB.add(fetchOperation) 

    //Tell CloudKit we've read the notifications 
    let operationRead = CKMarkNotificationsReadOperation(notificationIDsToMarkRead: notificationIDs) 
    self?.container.add(operationRead) 
    } 
} 

container.add(operation) 

Und der Fehler sagt:

<CKError 0x174241e90: "Change Token Expired" (21/1016); server message = "Error code: RESET_NEEDED"; uuid = ...; container ID = "...">

Die CKServerChangeTokendocumentation erwähnen nichts über das Token zurückzusetzen, und das Armaturenbrett Wolkenjunge bietet keine solche Option.

Irgendeine Idee, was ich tun soll?

Antwort

1

Dieser Fehlercode lautet CKErrorCodeChangeTokenExpired. Dies ist ein Hinweis darauf, dass Sie Ihre Änderungen erneut synchronisieren müssen.

https://developer.apple.com/documentation/cloudkit/ckerror/2325216-changetokenexpired

Dieser Fehlercode zurückgegeben wird, wenn die Änderungstoken zu alt ist, oder der Behälter wurde zurückgesetzt (Zurücksetzen des Containers ungültig alte Änderungstoken).

Die Kommentare zu diesen Fehlercode bezogen sind:

(der Code selbst beschreibt):

The previousServerChangeToken value is too old and the client must re-sync from scratch

(Bei verschiedenen Operationsabschluss/aktualisierten Blöcke fetch):

If the server returns a CKErrorChangeTokenExpired error, the serverChangeToken used for this record zone when initting this operation was too old and the client should toss its local cache and re-fetch the changes in this record zone starting with a nil serverChangeToken.

+0

Sinn macht . Vielen Dank, Dave! –

Verwandte Themen