当我需要使用 Firebase 将通知发送到特定设备时,这是 JSON 结构。那么我应该如何修改它以向所有设备或几个选定的设备发送相同的通知?
{ "notification": {
"title": "Quiz App",
"text": "Your Quiz has submitted Successfully."
},
"to" : "Unique Key"
}
在 android 中使用 Firebase 向所有设备发送推送通知的 JSON 结构是什么?
最佳答案
我有同样的需求,我通过将 to
设置为 /topics/all
并将 restricted_package_name
设置为我的包名称来解决它:
{
"to": "/topics/all",
"restricted_package_name": "<PACKAGE_NAME>",
"notification": {
"title": "<TITLE>",
"body": "<BODY>",
"click_action": "FCM_PLUGIN_ACTIVITY"
}
}
我发送的每条消息都由移动应用程序接收,无需以编程方式订阅主题。
关于android - 使用 Firebase 向所有已注册设备发送推送通知的 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39690293/