How To Get Message From Gcm Message Body In Android?
I have an app in which server sends some push notification using GCM server, The implementation is done on both side but i am facing problem is that i can't get notification from m
Solution 1:
Try ,
BundlenotificationData= bundle.getBundle("notification");
Stringbody= notificationData.getString("body");
Solution 2:
It received correct data only
Stringbodymessage= bundle.getString("body");
Problem is print message after converting Sting
Log.e(TAG, "onMessageReceived::" + message.toString());
Solution 3:
You can receive message in onMessage() function of GCMIntentService implementing class. I have created a function for getting proper message and key.
@OverrideprotectedvoidonMessage(Context context, Intent intent) {
dumpIntent(intent);
}
publicvoiddumpIntent(Intent i) {
Bundle bundle = i.getExtras();
if (bundle != null) {
Set<String> keys = bundle.keySet();
Iterator<String> it = keys.iterator();
while (it.hasNext()) {
String key = it.next();
Log.e("Intent Data", "[" + key + "=" + bundle.get(key) + "]");
}
}
}
After that you will easily set message with NotificationManager.
Post a Comment for "How To Get Message From Gcm Message Body In Android?"