提问人:Yunusbek Sadullaev 提问时间:8/19/2021 最后编辑:boburShoxYunusbek Sadullaev 更新时间:8/19/2021 访问量:114
iOS FCM 推送通知数据有效负载
iOS FCM push notification data payload
问:
我收到来自 FCM 的推送通知,如下所示。如何从 AppDelegate 中的“data”中获取数据
"to": "eTDYm1eJzUA-pRUNQ0pq9S:APA91CLfb1XQbsxUV0VIqTSV6A1YdXbKpRa9XkzZ6Px6Ww0-zQFU9OI0rgag_3Lwlu1yA1hbT-mQO6Ku37qNnuM6bKGfdOfAX-M0",
"notification":{
"body":"body",
"title":"This is title",
"sound": "default",
"mutable_content": true
},
"data" : {
"user_name": "user name",
}
}
先谢谢你!
答:
0赞
Yunusbek Sadullaev
8/19/2021
#1
Firebase 向我们发送 Map,我们应该将其转换为 [String: Any] 并从键中获取值
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
print("didReceive response TAPPED TO NOTIFICATION")
let userName = response.notification.request.content.userInfo["user_name"] as? [String : Any]
print(userName)
completionHandler()
}
评论