I\'m developing an iOS app that should receive push notifications sent from the Firebase console. I\'m using Swift 3 and iOS 10.
As recommended by the Firebase docum
You should be able to retrieve the body using something like:
let body = remoteMessage.appData["notification"]!["body"] as! String
print(body)
Thanks Arthur Thompson for your help, you gave me the idea. I post the answer in case someone else need it. I wrote
let d : [String : Any] = remoteMessage.appData["notification"] as! [String : Any]
let body : String = d["body"] as! String
print(body)
You should be able to print any line from the response with this :
let response = remoteMessage.appData
print(response[AnyHashable("notification")] as Any)
Apple documentation on AnyHashable : https://developer.apple.com/reference/swift/anyhashable
I had exactly the same problem with Firebase messaging and extracting the data and this works like a charm. (Swift 3)
print("====")
let d : [String : Any] = remoteMessage.appData["notification"] as! [String : Any]
let body : String = d["body"] as! String
let click_action : String = d["click_action"] as! String
let title : String = d["title"] as! String
print(body)
print(title)
print(click_action)
print("=====")