我的订阅在 iOS 9 上运行正常,但自从我更新后,出现了一个非常奇怪的错误。我有两种相同的订阅方法,除了它们管理的字段。这是代码:
let meetingSubscriptionPredicate = Predicate(format: "Users CONTAINS %@", (id?.recordName)!)
let meetingSubscription = CKQuerySubscription(recordType: "Meetings", predicate: meetingSubscriptionPredicate, options: .firesOnRecordCreation)
let notification = CKNotificationInfo()
notification.alertBody = "Meeting Created!"
notification.shouldBadge = true
notification.accessibilityPerformEscape()
meetingSubscription.notificationInfo = notification
database.save(meetingSubscription) { (result, error) -> Void in
if error != nil {
print(error!.localizedDescription)
}
}
let universitiesSubscriptionPredicate = Predicate(format: "Name = %@", self.UniversityTextField.text!)
let universitiesSubscription = CKQuerySubscription(recordType: "Universities", predicate: universitiesSubscriptionPredicate, options: .firesOnRecordCreation)
let universitiesNotification = CKNotificationInfo()
universitiesNotification.alertBody = "Your university is now on Meet'em!"
universitiesNotification.shouldBadge = true
universitiesNotification.accessibilityPerformEscape()
universitiesSubscription.notificationInfo = universitiesNotification
database.save(universitiesSubscription, completionHandler: { (saved, error) in
if error != nil {
print(error!.localizedDescription)
}
else {
print("University subscription created")
}
})
奇怪的是 session 订阅被保存了,而大学的订阅没有。我已经仔细检查了名称,它们都在仪表板上。除此之外,我的手机上没有收到任何通知……
最佳答案
在网上其他地方找到您可以尝试重置您的开发环境。就我而言,我尝试使用的谓词未设置为可查询。在您定义记录类型的地方打勾。它有一天起作用而不是另一天起作用的原因可能是由于从开发转移到生产。那时你被要求优化索引,并且可能在这里放弃了对给定谓词进行搜索的能力。无论如何,这对我来说似乎就是这种情况。
关于swift - CK订阅错误iOS10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38445396/