Reputation: 125
I have implemented firebase push notification in my app. Now I'm receiving notification details like this,
[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";
}]
I have tried to get the value, but I'm getting it nil like this,
let notification = userInfo["type"] as? [AnyHashable: Any]
print(notification)
How can I get all the values from the notification?
Upvotes: 0
Views: 751
Reputation: 54706
You're parsing the payload incorrectly. Why would you expect the value of the key gcm.notification.type
to be another Dictionary
? It is clearly a single value of type String
.
let notificationType = userInfo["gcm.notification.type"] as? String
Upvotes: 1