我有一个应用程序在哪个服务器使用GCM服务器发送一些推送通知,实现在两端完成,但我面临的问题是,我无法从消息正文获取通知,它总是向我显示“null”。但是我可以使用调试在消息体内看到消息。如何从android中的GCM消息体获取消息?
String message = bundle.getString("message");
Log.e(TAG, "onMessageReceived::" + message);
Log.e(TAG, "from::" + from);
和消息主体是: -
Bundle[{google.sent_time=1497866966996, google.message_id=0:1497866967011288%466cbbd8466cbbd8, notification=Bundle[{priority=high, body=Your wallet has been credited with 1.000 point(s)., title=Wallet credited}], collapse_key=com.s.baty}]
您必须将您的通知作为JSON发送。你的身体应该包含这样的内容{“gcm.notification.title”:“”, “gcm.notification.body”:“”},你可以得到像这样的身体bundle.getString(“gcm.notification.body” ) –