我想用谷歌的 fcm 发送一条消息,但我需要一个名为“Message”的类,但它在我的导入中不存在。(我实现了 com.google.firebase:firebase-messaging:18.0.0)
我尝试使用远程消息类,但它不适合我的问题。
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
我想使用这个示例代码:
// 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);
需要的类是这样的:https://firebase.google.com/docs/reference/admin/java/reference/com/google/firebase/messaging/Message但它不存在。