Firebase Cloud Messaging - Send message to all users(Firebase 云消息传递 - 向所有用户发送消息)
问题描述
我是使用 Firebase 云消息的新手.我构建了一个 IOS 应用程序来接收推送通知.该应用程序运行良好.我从 Firebase 控制台发送消息并且它们显示正确.
I'm new using the Firebase Cloud Message. I built an IOS app to receive push notifications. The app works fine. I send messages from the Firebase console and they're displayed correctly.
现在我正在尝试构建一个 Web api 以允许我的客户发送推送消息(无需访问 firebase 控制台).研究文档 here 我意识到我一直都有to",表示组、主题或设备 ID.
Now I`m trying to build an web api to allow my customer to send the push messages (without accessing the firebase console). Studying the documentation here I realized that I've always to have a "to", meaning a group, topic or device id.
我的问题是:我可以向所有设备发送消息吗(就像我可以在控制台中那样)?我是的,怎么会?
My question is: can I send a message to all devices (like I can do in the console)? I yes, how so?
提前致谢!
推荐答案
你可以利用主题.鉴于您的所有用户都订阅了特定的用户.就像我在这里提到的(删除了一些部分,如果需要,只需检查它们):
You can make use of topics. Given that all of your users are subscribed to a specific one. Just like what I mentioned here (removed some parts, just check them out if you want):
如果您正在寻找一个有效负载参数来指定您打算将消息发送给所有用户,那么很遗憾,它不存在.
If you are looking for a payload parameter to specify that you intend the message for all your users, unfortunately, it doesn't exist.
通常,当向多个用户发送通知时,您可以使用 registration_ids 参数而不是 to.但是,它最多只允许 1000 个注册令牌.如果您打算使用它,您可以发出 1000 个注册令牌的批量请求,遍历您存储在应用服务器中的所有注册令牌.
Commonly, when sending notifications to multiple users, you can make use of the registration_ids parameter instead of to. However, it only has a maximum of 1000 registration tokens allowed. If you intend to use this, you can make batch requests of 1000 registration tokens each, iterating over all the registration tokens you've stored in your app server.
但是,请记住,不支持对发送到主题的消息进行诊断.
这篇关于Firebase 云消息传递 - 向所有用户发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Firebase 云消息传递 - 向所有用户发送消息
基础教程推荐
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
