Firebase云消息传递 - 将消息发送给所有用户 [英] Firebase Cloud Messaging - Send message to all users

查看:504
本文介绍了Firebase云消息传递 - 将消息发送给所有用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的使用Firebase云消息。我建立了一个IOS应用程序来接收推送通知。该应用程序工作正常。我从Firebase控制台发送消息并正确显示。



现在我正在尝试构建一个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云消息传递 - 将消息发送给所有用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆