我正在为以下订阅而苦苦挣扎:
let predicate = NSPredicate(format: "gc_alias != %@ AND distanceToLocation:fromLocation:(%K,%@) < %f",
self.localPlayer!.alias!,
"location",
self.currentLocation!,
10)
let subscription = CKSubscription(recordType: "Player", predicate: predicate, options: .FiresOnRecordCreation)
subscription.zoneID = nil
let notification = CKNotificationInfo()
notification.alertBody = "Nearby Player within Range!"
notification.soundName = UILocalNotificationDefaultSoundName
subscription.notificationInfo = notification
let container = CKContainer.defaultContainer()
let publicDb = container.publicCloudDatabase
publicDb.saveSubscription(subscription) { (result, error) -> Void in
if error != nil {
print(error!.localizedDescription)
} else {
print("SUBSCRIBED SUCCESS")
print(result)
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "subscribed")
}
}
基本上,当创建或更新新的 Player 记录时,我会记录用户的位置。
当用户 B 创建或更新他们的玩家记录并且在 10KM 内时,我希望通过推送通知用户 A。
我相信我在我的应用程序中正确设置了推送权限(例如,在创建他们的子之前提示用户确认这一点)。
没有推送到达。有任何想法吗?我是否有一些基本的 CK 误解?