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

查看:37
本文介绍了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 云消息传递 - 向所有用户发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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