【发布时间】:2019-08-24 03:43:54
【问题描述】:
如何访问传入推送通知的标题?
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
// With swizzling disabled you must let Messaging know about the message, for Analytics
// Messaging.messaging().appDidReceiveMessage(userInfo)
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
self.numberOfNotifications += 1
}
// Print full message.
print("Message: ", userInfo)
//completionHandler([])
// Change this to your preferred presentation option
let data = userInfo.values as []//I would like to access the data here...
completionHandler([.alert, .sound])
}
在上面我收到一条通知,我想检查特定文本的标题。如何以字符串形式访问测试来执行此操作?
【问题讨论】:
标签: ios swift push-notification notifications