iOS 12中未发送本地位置通知

时间:2018-12-02 18:33:57

标签: ios swift notifications location

我有一个使用UNLocationNotificationTrigger来基于用户位置传递通知的应用程序。当我测试我的应用程序时,有时会注册该用户输入的特定区域,但不会在输入区域时发出通知。有时候它可以完美地工作,但是我想知道为什么这每次都行不通。还有其他人有类似的问题吗?如果有人可以对此问题做一个简短的解释,我将不胜感激:)

这是注册通知的代码:

let notification = UNMutableNotificationContent()

notification.title = "Notification title"
notification.subtitle = "Notification subtitle"
notification.body = "Notification body"

let notificationTrigger = UNLocationNotificationTrigger(region: enteredRegion, repeats: true)
let notificationRequest = UNNotificationRequest(identifier: "id12494", content: notification, trigger: notificationTrigger)

UNUserNotificationCenter.current().add(notificationRequest, withCompletionHandler: nil)

0 个答案:

没有答案
相关问题