调用remoteMessage.getNotification()
返回null
,调用时我得到一个奇怪的对象,它具有如下所列remoteMessage.getData()
的初始属性。_wp={
我每次都需要提取警报属性,但我不确定如何。
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
RemoteMessage.Notification notification = remoteMessage.getNotification();
Map<String, String> data = remoteMessage.getData();
Log.d("DATA", remoteMessage.getData().toString());
sendNotification(data);
}
远程数据日志返回以下内容。所以我似乎无法获得构建通知所需的标题和文本。
{_wp={"c":"01euntvtna3epk83","alert":{"text":"Body text","title":"test"},"receipt":false,"type":"simple","targetUrl":"wonderpush:\/\/notificationOpen\/default","n":"01eunu08bjla8303","reporting":{"campaignId":"01euntvtna3epk83","notificationId":"01eunu08bjla8303"},"receiptUsingMeasurements":true}, alert=Body text}
我基本上想在使用时使用它们NotificationCompat.Builder
.setContentTitle(title)
.setContentText(text)
任何帮助将不胜感激。