我已经在我的应用中实现了 firebase 推送通知。现在我收到这样的通知详细信息,
[AnyHashable("gcm.notification.details"): +12345, AnyHashable("gcm.notification.type"): video, AnyHashable("gcm.notification.group_name"): test, AnyHashable("gcm.message_id"): 0:1538469426956356%def3521bdef3521b, AnyHashable("google.c.a.e"): 1, AnyHashable("aps"): {
alert = "+12345";
}]
我试图获得价值,但我像这样获得零,
let notification = userInfo["type"] as? [AnyHashable: Any]
print(notification)
如何从通知中获取所有值?
您正在错误地解析有效负载。为什么您希望 key 的值gcm.notification.type
是 another Dictionary
?它显然是 type 的单个值String
。
let notificationType = userInfo["gcm.notification.type"] as? String
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句