【发布时间】:2017-08-16 00:23:09
【问题描述】:
CKContainer.discoverAllIdentities 请求在我的 CloudKit 应用程序中总是失败。它在几天内不断失败。
失败的代码的简化版本(导致相同的错误)是:
private func getContacts(completion: (([CKUserIdentity]?) -> Void)?) {
container.status(forApplicationPermission: .userDiscoverability) { [weak self] status, error in
if let error = error {
print(error)
}
switch status {
case .granted:
self?.discover(completion: completion)
default:
print("status not granted")
}
}
}
private func discover(completion: (([CKUserIdentity]?) -> Void)?) {
let op = CKDiscoverAllUserIdentitiesOperation()
op.qualityOfService = .userInitiated
op.discoverAllUserIdentitiesCompletionBlock = { error in
if let error = error {
print(error)
}
}
op.userIdentityDiscoveredBlock = { identity in
print(identity)
}
op.start()
}
这会导致将错误传递给op.discoverAllUserIdentitiesCompletionBlock。日志中的错误描述为:
<CKError 0x1c4a51a60: "Server Rejected Request" (15/2000); server message = "Internal server error"; uuid = F67453B9-712D-4E5E-9335-929123E3C978; container ID = "iCloud.com.huntermaximillionmonk.topdraw">
以前,此操作可以工作,但仅适用于某些 iCloud 用户。现在它不适用于我的两个测试用户。
【问题讨论】:
-
遇到同样的问题,如果您设法解决了,请告诉我。
-
还是有问题。我发现它只发生在有很多联系人的设备上。尝试在联系人很少 (
-
那好点试试看!
-
我刚刚尝试了 400 个联系人,操作没有失败。似乎还有其他问题。我能够找到发现的联系人。
-
此错误是 iOS 11 中的错误。同样的代码在 iOS 10 下也可以正常工作。我强烈建议任何受 iOS 11 中此问题影响的人都应该向 Apple 提交错误报告。