【发布时间】:2015-04-15 07:30:09
【问题描述】:
几个星期以来,我的应用无法重置 CloudKit 徽章。我收到“网络故障”错误。它以前确实有效,我没有更改任何代码。我找不到有关更改功能的任何信息。这是 CloudKit 错误吗?我应该提交雷达吗?还是我做错了什么?
这是我使用的代码:
public func setBadgeCounter(count:Int) {
let badgeResetOperation = CKModifyBadgeOperation(badgeValue: count)
badgeResetOperation.modifyBadgeCompletionBlock = { (error) -> Void in
func handleError(error: NSError) -> Void {
EVLog("Error: could not reset badge: \n\(error)")
}
self.handleCallback(error, errorHandler: handleError, completionHandler: {
UIApplication.sharedApplication().applicationIconBadgeNumber = count
})
}
CKContainer.defaultContainer().addOperation(badgeResetOperation)
}
internal func handleCallback(error: NSError?, errorHandler: ((error: NSError) -> Void)? = nil, completionHandler: () -> Void) {
if (error != nil) {
EVLog("Error: \(error?.code) = \(error?.description) \n\(error?.userInfo)")
if let handler = errorHandler {
handler(error: error!)
}
} else {
completionHandler()
}
}
我得到的错误是:
04/15/2015 09:12:28:837 AppMessage)[10181:.] EVCloudKitDao.swift(202) handleCallback(_:errorHandler:completionHandler:):
Error: Optional(4) = Optional("<CKError 0x7fb451c77c10: \"Network Failure\" (4/-1003); \"A server with the specified hostname could not be found.\">")
Optional([NSErrorFailingURLStringKey: https://ckdevice.icloud.com/api/client/badgeUpdate, _kCFStreamErrorCodeKey: 8, NSDebugDescription: NSURLErrorDomain: -1003, NSLocalizedDescription: A server with the specified hostname could not be found., NSErrorFailingURLKey: https://ckdevice.icloud.com/api/client/badgeUpdate, NSUnderlyingError: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x7fb45351a890 {NSErrorFailingURLStringKey=https://ckdevice.icloud.com/api/client/badgeUpdate, NSErrorFailingURLKey=https://ckdevice.icloud.com/api/client/badgeUpdate, _kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, NSLocalizedDescription=A server with the specified hostname could not be found.}, _kCFStreamErrorDomainKey: 12])
04/15/2015 09:12:28:839 AppMessage)[10181:.] EVCloudKitDao.swift(788) handleError:
Error: could not reset badge:
<CKError 0x7fb451c77c10: "Network Failure" (4/-1003); "A server with the specified hostname could not be found.">
可以在https://github.com/evermeer/EVCloudKitDao找到有这个问题的完整功能应用程序
【问题讨论】:
-
它看起来像一个 CloudKit 错误。见devforums.apple.com/message/1126244#1126244
-
我在bugreport.apple.com 提交了一份错误报告,ID 为 20566994
-
我得到了一位苹果工程师的回复:20125644 重复(打开)
-
3 个月后仍然无法正常工作.. :(
-
任何修复了吗?我刚刚得到了同样的错误。在学习 EVCloudKitDao 的功能时并不奇怪
标签: ios reset badge cloudkit server-error