gpt4 book ai didi

android - 使用 Firebase 向所有已注册设备发送推送通知的 JSON 数据

转载 作者:行者123 更新时间:2023-12-04 02:09:47 24 4
gpt4 key购买 nike

当我需要使用 Firebase 将通知发送到特定设备时,这是 JSON 结构。那么我应该如何修改它以向所有设备或几个选定的设备发送相同的通知?

{ "notification": {
"title": "Quiz App",
"text": "Your Quiz has submitted Successfully."
},
"to" : "Unique Key"
}

在 android 中使用 Firebase 向所有设备发送推送通知的 JSON 结构是什么?

最佳答案

我有同样的需求,我通过将 to 设置为 /topics/all 并将 restricted_pa​​ckage_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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com