我想从我的 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。