相关疑难解决方法(0)

如何从 Android 向主题发送 firebase 消息

我想从我的 Android 应用程序中向 FCM 主题发送消息。通过 Firebase 控制台发送消息运行良好,但是一旦用户执行特定操作,我希望将消息发送给订阅特定主题的所有其他用户。

在文档中有这个代码:

// The topic name can be optionally prefixed with "/topics/".
String topic = "highScores";

// See documentation on defining a message payload.
Message message = Message.builder()
.putData("score", "850")
.putData("time", "2:45")
.setTopic(topic)
.build();

// Send a message to the devices subscribed to the provided topic.
String response = FirebaseMessaging.getInstance().send(message);
// Response is a message ID string.
System.out.println("Successfully sent message: " + response);
Run Code Online (Sandbox Code Playgroud)

我不知道是哪个班级Message的。显然不是RemoteMessage

android firebase-cloud-messaging

3
推荐指数
1
解决办法
4238
查看次数

标签 统计

android ×1

firebase-cloud-messaging ×1