【发布时间】:2018-01-01 04:03:30
【问题描述】:
来自 Defining message payload 的 Firebase 云消息传递文档:
您可以通过创建一个对象来指定一种或两种消息类型 数据和/或通知键。
文档给出了组合消息的示例:
var payload = {
notification: {
title: "$GOOG up 1.43% on the day",
body: "$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day."
},
data: {
stock: "GOOG",
open: 829.62,
close: "635.67"
}
};
同样来自Handle notification messages in a backgrounded app的文档:
这包括同时包含通知和数据负载的消息 (以及从通知控制台发送的所有消息)。在这些 在这种情况下,通知会发送到设备的系统托盘,并且 数据负载在您的意图的附加内容中传递 启动器活动。
我正在发送带有此有效负载的通知:
const payload = {
notification: {
title: '...',
body: '...',
},
data: {
test: "test"
},
};
admin.messaging().sendToDevice(tokens, payload).then(...)
但extras 始终为空:
Intent intent = getIntent();
if (intent != null) {
Bundle extras = intent.getExtras();
if (extras != null) {
// do something
}
}
我做错了什么?
【问题讨论】:
标签: android firebase firebase-cloud-messaging