【发布时间】:2018-11-06 21:19:05
【问题描述】:
无法读取 FCM 通知用户数据,我正在尝试这个 -
let userInfo = response.notification.request.content.userInfo
if let jsonResult = userInfo as? Dictionary<String, AnyObject> //**Getting error on this line**
{
if let notifyType =
jsonResult["gcm.notification.notification_type"] as? String ?? ""
{
print(notifyType)
}
}
【问题讨论】:
-
错误出现在哪一行?
-
@iDeveloper 您还必须显示您的 JSON 响应。请编辑您的问题
-
一些旁注:如果让 X 表示条件绑定,如果右侧是可选的。既然你用了……?? "",表示当值为 nil 时,您已经提供了默认值,这意味着它不是可选值。如果 let X 因此无效。
-
@J.Doe 感谢您的深入描述。
标签: swift firebase push-notification firebase-cloud-messaging