Bundle
[{
google.sent_time=1487229288769,
gcm.notification.created_at=2017-02-16 12:44:52,
gcm.notification.e=1,
gcm.notification.Content_available=1,
gcm.notification.badge=1,
gcm.notification.title=, from=388143837768,
google.message_id=0:1487229288775757%19aca14d19aca14d,
gcm.notification.body=hi,
gcm.notification.uid=160,
collapse_key=com.sid.Smessenger
}]
I am getting above response from fcm and I want to convert it into json please check above android code.
getting response from remoteMessage.
I am not getting data in getBody().
getting null value only.
public void onMessageReceived(RemoteMessage remoteMessage)
{
Log.d(TAG, "FROM: " + remoteMessage.getFrom());
remoteMessage.getFrom();
if (remoteMessage.getData().size() > 0)
{
Log.d(TAG, "Message data: " + remoteMessage.getData());
}
if (remoteMessage.getNotification() != null)
{
Log.d(TAG, "Message body:" +
remoteMessage.getNotification().getBody());
String questionId =
remoteMessage.getData().get("gcm.notification.gid");
String userId =
remoteMessage.getData().get("gcm.notification.uid");
Log.e("Group ID", questionId);
Log.e("U ID", userId);
Bundle bundle = new Bundle();
for (Map.Entry<String, String> entry :
remoteMessage.getData().entrySet()) {
bundle.putString(entry.getKey(), entry.getValue());
Log.e(entry.getKey(), entry.getValue());
//run it/// and get notification///
}
// String created_at = remoteMessage.
sendNotification(remoteMessage.getNotification().getBody());
}
// String value = bundle.getString("request");
}