I need to parse the notification body as a HashMap but the notification always displayed as a JSON string instead of the parsed message. Any ideas why?[Image of the Android notification received] (https://i.stack.imgur.com/IQIPb.jpg)
override fun onMessageReceived(message: RemoteMessage) {
super.onMessageReceived(message)
Log.i("FirebaseService ", "Message :: $message")
val title = message.notification!!.title
val body = message.notification!!.body
Log.i(TAG, "Messaging Service $body")
val notificationBody: HashMap<String, String> = Gson().fromJson(body, HashMap::class.java) as HashMap<String, String>
val messageBody = notificationBody["message"]
val rideId = notificationBody["rideId"]
if(notificationBody["type"] == "TRACK"){
showNotification(title!!, messageBody!!)
}else{
// Something else
}
}
I have tried to parse the remote message using the GSON library, but the notification always return the full body