问题描述
我想向所有设备发送消息,但我只向一个设备发送消息,这是我发送消息的方式:我只能向一个用户发送消息,当我在我的发送消息方法中删除它时:
I want to send a message to all device but I only send to one device this is how I send a message : I only can send message to one user , when I remove this at my method to send a message:
当我有这条线时,消息不会发送给任何人我只向一个用户发送消息.我如何向每个人发送消息?
a message is not send to nobody when I have this line I send a message to only one user . How I can send a message to every one ?
推荐答案
Firebase 支持所谓的 topics
Firebase supports what is called topics
因此,您可以向某个主题发送消息,订阅该主题的所有设备都会收到推送.
So you can send a message to a topic and all the devices subscribed to that topic will get the push.
您可以有一个名为 all
的主题,然后将每个设备注册到该主题.
You can have a topic called all
and then register each device to that.
这是您的注册方式
然后,您只需向该主题发送通知,您的所有用户都会收到它.
Then you can just fire notifications to that topic and all your users will get it.
然后替换这一行
与
在这种情况下,您的主题名称是 all
In this case your topic name is all
这篇关于Java Firebase 云消息.向所有人发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!