Ral*_*kum 8 android firebase firebase-cloud-messaging
我的firbase RemoteMessage有一个带有12个键值对的mBundle,根据调试器,这些字段被填充
.
但是当我说:remoteMessage.getData();结果ArrayMap的Map<String, String>大小为0,因此没有元素.
如何访问remoteMessage的Map?
小智 7
我知道可能会晚,但是您可以从RemoteMessage中的Notification Object获取数据
String title = remoteMessage.getNotification().getTitle();
String body = remoteMessage.getNotification().getBody();
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助
小智 6
我也遇到过同样的问题.
最后解决了这个问题.
就我而言,服务器端发送FCM有效负载问题.
像这样.
options = {
priority: 'high',
notification: {
title: "title",
body: "message",
url: "some_url",
image_url: "some_image_url"
}
Run Code Online (Sandbox Code Playgroud)
我更新如下,
options = {
priority: 'high',
notification: {
title: "title",
body: "message",
},
data: {
url: "some_url",
image_url: "some_image_url"
}
Run Code Online (Sandbox Code Playgroud)
之后,我可以获得有效载荷值remoteMessage.getData().
| 归档时间: |
|
| 查看次数: |
3321 次 |
| 最近记录: |