【发布时间】:2016-07-18 20:23:42
【问题描述】:
我的订阅在 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")
}
})
奇怪的是会议订阅被保存了,而大学的订阅却没有。我已经仔细检查了这些名称,它们在仪表板上都是正确的。除此之外,我没有在我的手机上收到任何通知......
【问题讨论】:
-
遇到同样的问题,你找到解决办法了吗?
标签: swift push-notification swift3 xcode8 ios10