Using FirebaseMessagingService 使用 PHP 发送远程消息。到目前为止它工作正常,突然应用程序停止接收通知,调试后我发现
onMessegeReceived(remoteMessage)
remoteMessage.getData() returns null Array Map.
但我可以在捆绑包中看到有效载荷数据
Bundle[{google.delivered_priority=high, google.sent_time=1556008551748, google.ttl=2419200, google.original_priority=high,
from=982221224130,
google.message_id=0:1556008551825452%903f05e2903f05e2,
gcm.notification.data={"image":"https:url","nId":1313,"time":"14:05:51","priority":"normal","title":"testttt","message":"","type":"1"}, google.c.a.e=1, collapse_key=com.sam.grapemundo}]
我希望结果 remoteMessage.getData(( 返回
data={"image":"https:url","nId":1313,"time":"14:05:51","priority":"normal","title":"testttt","message":"","type":"1"}, google.c.a.e=1, collapse_key=com.sam.grapemundo}]
首先,您必须检查通知是否触发:-
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e(TAG, "From: " + remoteMessage.getFrom());
Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());
if (remoteMessage.getNotification() == null)
return;
// Check if message contains a notification payload.
if(remoteMessage.getNotification() != null) {
handleNotification(remoteMessage, remoteMessage.getNotification().getBody(), remoteMessage.getNotification().getTitle());
}