0
私はの新機能です。ビーコンプログラミング.iアプリを閉じているときにを見積もります。ビーコンを検出します。ビーコンが検出されたら、特定の通知を発します。どのように私はそれを行うことができますか? 私に提案をお願いします。私は次のコードを実行しました。しかし、私は通知を得ることができませんアプリがアイオスで殺されたときに推定ビーコンを検出するにはどうすればよいですか?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
beaconManager.delegate = self
beaconManager.startMonitoring(for: region)
beaconManager.startRangingBeacons(in: region)
}
func beaconManager(_ manager: Any, didEnter region: CLBeaconRegion) {
NSLog("beaconManager : didEnter Called")
let content = UNMutableNotificationContent()
content.title = "Beacon Detected"
content.body = "Enter region"
content.sound = UNNotificationSound.default()
let trigger = UNLocationNotificationTrigger(region:region, repeats:false)
let request = UNNotificationRequest(identifier: "Enter region", content: content, trigger: trigger)
center.add(request) { (error) in
if let error = error {
print(error.localizedDescription)
}
}
}
func beaconManager(_ manager: Any, didExitRegion region: CLBeaconRegion) {
NSLog("beaconManager : didExitRegion Called")
let content = UNMutableNotificationContent()
content.title = "Beacon Detected"
content.body = "Exit region"
content.sound = UNNotificationSound.default()
let trigger = UNLocationNotificationTrigger(region:region, repeats:false)
let request = UNNotificationRequest(identifier: "Enter region", content: content, trigger: trigger)
center.add(request) { (error) in
if let error = error {
print(error.localizedDescription)
}
}
}
私はそれを試みましたが、何も起こりません。 –
あなたの試したコードを表示してください。 – jegadeesh
あなたの質問にコードを書いてください。コメントでそれらを読むのは難しい。 – jegadeesh