나는 다음 구독 고군분투 : 새로운 플레이어 레코드를 만들거나 업데이트 할 때CloudKit 구독 비애는
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")
}
}
는 기본적으로, 사용자의 위치를 기록합니다.
사용자 B가 플레이어 레코드를 생성하거나 업데이트 할 때 사용자 A가 푸시를 통해 알림을 받고 10KM 내에 있어야합니다.
나는 내 앱에서 밀어 넣기 권한 설정을 올바르게했다고 믿는다. (예를 들어 사용자는 자신의 하위가 생성되기 전에이를 확인하라는 메시지가 표시된다.)
푸시가 발생하지 않습니다. 어떤 아이디어? 근본적인 CK 오해를 겪고 있습니까?
는 당신이 CK 레코드를 작성하고 알림을 등록 곳에 코드를 추가 할 수 있습니다 이런 식으로 뭔가 트릭을 할한다고? – diegog
distanceToLocation : fromLocation :()은 킬로미터가 아닌 미터를 반환합니다. 10 대신 10000을 통과해야합니다. – diegog
Diegog FTW! 미터가 그것을 치는 것처럼 보였다! 놀랍게도 웹상의 잘못된 정보가 있습니다. : | – Genericrich