2
爲什麼在我的通知類中remoteMessage.getData()將變爲null? 不知道有什麼問題,請幫助我!從onMessageReceived方法中的FCM中獲取RemoteMessage的值
Bundle[
{
google.sent_time=1472704247501,
gcm.notification.e=1,
gcm.notification.title=Testpush,
from=491403630981,
google.message_id=0: 1472704247506889%9831a5799831a579,
gcm.notification.body=Thisisatestnotificationfromthewebapi,
gcm.notification.data={
'order_id': '795'
},
collapse_key=client
}
]
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.w("fcm", "received notification");
Log.e("dataChat", remoteMessage.getData().toString());
String data="";
try
{
Map<String, String> params = remoteMessage.getData();
JSONObject object = new JSONObject(params);
Log.e("JSON_OBJECT", object.toString());
data=object.getString("order_id");
}catch (Exception e){
}
sendNotification(remoteMessage.getNotification().getTitle(),remoteMessage.getNotification().getBody(),data);
}
FCM採取RemoteMessage參數onMessageReceived() –
有你從firbase控制檯配置文件? –
...是的,我知道了 –