【发布时间】:2019-10-19 14:26:31
【问题描述】:
我想在单击操作按钮后获取通知的正文内容/文本并将该文本保存在变量中。
例如,我收到一条通知,并且有 2 个操作按钮。如果我单击其中的第一个,它将通知的正文内容保存在名为“内容”的变量中。如果我点击第二个,它将获得通知标题并将其保存在名为“Title”的变量中。
正文和标题内容是可变的。
实例:
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if response.actionIdentifier == "Yes" {
//var Content = the content of the Notification
} else {
//var Title = the Title of the Notification
}
scheduleNotification()
completionHandler()
}
【问题讨论】:
标签: ios swift unusernotificationcenter