我正在尝试使用CloudKit订阅推送通知.我收到这个错误:
<CKError 0x170c5b1e0: "Unknown Item" (11/2003); server message = "could not find required field fieldID="25""
从这段代码:
let subscription = CKSubscription(recordType: "PlayerData",predicate: NSPredicate(format: "TRUEPREDICATE"),options: CKSubscriptionOptions.FiresOnRecordCreation) let notificationInfo = CKNotificationInfo() notificationInfo.shouldBadge = false subscription.notificationInfo = notificationInfo PublicDb.saveSubscription(subscription,completionHandler: { (returnedSubscription: CKSubscription!,error: NSError!) in println("\(error)") })
但我没有一个名为“fieldID”的字段,也没有在我的整个项目中对它有任何引用.我不知道25来自哪里.如果我更改记录类型和/或NSPredicate,它仍然会发生.
我也试过设置这个,但没有
notificationInfo.shouldSendContentAvailable = true
解决方法
通过重置开发环境来修复它.希望同样的事情不会发生在prod上.