问题描述
我正在从后台任务发送这样的本地通知:
let content = UNMutableNotificationContent()
content.title = "Title"
content.subtitle = "Subtitle"
content.categoryIdentifier = ...
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5,repeats: false)
let request = UNNotificationRequest(identifier: ". . .",content: content,trigger: trigger)
而且我正在尝试管理用户是否点击它。
如果应用程序是背景或前景,则可以使用我的应用程序委托方法来处理(我需要在点击时显示一个新的ViewController)
func userNotificationCenter(_ center: UNUserNotificationCenter,didReceive response: UNNotificationResponse,withCompletionHandler completionHandler: @escaping () -> Void) { // ... }
发件人:UNUserNotificationCenterDelegate
但是,如果我在应用程序终止的情况下单击通知,则不会发生任何事情。
我正在努力
if(launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] != nil) {
Log.debug("LaunchOption remote notification tapped")
}
但是我不知道如何在终止应用程序的情况下处理通知中的轻击。我需要做的只是显示一个newViewController
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)