2
私の通知クラスでremoteMessage.getData()がnullになるのはなぜですか? 問題が何かわからない、私を助けてください!FCMからRemoteMessageの値をonMessageReceivedメソッドで取得する
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は(onMessageReceivedでRemoteMessageパラメータを取り、これを試してみてください) –
あなたはfirbaseコンソールから設定ファイルを取得する必要がありますか? –
...はい私はそれを持って –