【发布时间】:2021-09-06 07:10:27
【问题描述】:
是否可以获得点击的本地通知按钮的 UNNotificationRequest 标识符或有关通知的任何其他信息?也许通过委托?
谢谢
【问题讨论】:
标签: swift notifications identifier unnotificationrequest
是否可以获得点击的本地通知按钮的 UNNotificationRequest 标识符或有关通知的任何其他信息?也许通过委托?
谢谢
【问题讨论】:
标签: swift notifications identifier unnotificationrequest
通知的标识符是这样获取的:
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let identifier = response.notification.request.identifier
switch response.actionIdentifier {
case "snoozeAction":
print ("Snooze Tapped - identifier :", identifier)
nc.post(name: Notification.Name("didTapSnooze"), object: nil)
default:
break
}
completionHandler()
}
【讨论】: