0

次のコードを使用して、場所に基づくリマインダーを購読しました。

let center = CLLocationCoordinate2D(latitude: tapp.location.latitude, longitude: tapp.location.longitude)
let region = CLCircularRegion(center: center, radius: CLLocationDistance(tapp.reminder), identifier: tapp.name)
locationManager.distanceFilter = 100
locationManager.startMonitoring(for: region)
region.notifyOnEntry = true
region.notifyOnExit = false
let trigger = UNLocationNotificationTrigger(region: region, repeats: false)
let request = UNNotificationRequest(identifier: "\(tapp.location.latitude)|\(tapp.location.longitude)", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)

このコードは、iOS シミュレーターでリージョンに入ったときに通知するように機能しますが、アプリを物理デバイスにロードしてそのリージョンに入っても、通知されません。

位置情報ベースの通知をサブスクライブできるかどうかに影響を与える低電力モードについて何か読んだことを覚えていますが、アプリがバックグラウンド アップデートを受信するのを止めるものは他にありますか? また、私のコードは正しいですか?

4

0 に答える 0