【发布时间】:2021-02-22 18:33:41
【问题描述】:
调用 remoteMessage.getNotification() 返回 null 并且
当调用remoteMessage.getData() 时,我得到一个奇怪的对象,它有一个初始属性_wp={,如下所示。我每次都需要提取 alert 属性,但我不确定如何。
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)
任何帮助将不胜感激。
【问题讨论】:
标签: java android firebase wonderpush