斯威夫特 3.1,Xcode 8.3.3
我不断收到来自 CloudKit 的错误,我不知道该怎么办。
我正在跟踪来自 CloudKit 的通知,如下所示:
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)
错误说:
<CKError 0x174241e90:“更改令牌已过期”(21/1016);服务器消息=“错误代码:RESET_NEEDED”;uuid = ...; 容器 ID = "...">
CKServerChangeToken
文档没有提到任何关于重置令牌的内容,CloudKit 仪表板也没有提供任何此类选项。
知道我应该做什么吗?