现在我正在尝试构建一个web api,允许我的客户发送推送消息访问Firebase控制台)。学习这里的文档我意识到我一直都有一个到,意思是一个组,主题或设备ID。
我的问题是:我可以向所有设备发送消息(就像我可以在控制台中一样)?我是的,怎么这样? 提前致谢!
解决方案你可以使用主题。鉴于您的所有用户都订阅了特定的用户。就像我提到的这里(删除了一些部分,只是检查出来,如果你想):
如果您正在查找有效负载参数以指定您希望所有用户的消息,那么不幸的是它不存在。
通常,向多个用户发送通知时,可以使用 registration_ids 参数而不是来 code>。但是,最多只能有1000个注册令牌。如果你打算使用它,你可以批量请求1000个注册令牌,迭代你存储在你的应用服务器上的所有注册令牌。
然而,请记住,不支持发送给主题的邮件的诊断。
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.
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?
Thanks in advance!
解决方案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.
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.
However, do keep in mind that Diagnostics for messages sent to Topics are not supported.
更多推荐
Firebase云消息传递
发布评论