firebase-messaging(第 21 版)库 (JAVA) 中缺少一些 类
Lack of some classes in the firebase-messaging( vers. 21) library (JAVA)
我正在关注此 guide 以向某些设备发送消息。
关于构建发送请求的部分,它说:
// 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);
当我尝试导入消息 class 时,IDE 告诉我没有库,为什么?
也许它已被弃用但文档尚未更新?
谢谢
您复制的代码正在使用 Java 的 Firebase Admin SDK,无法在 Android 上使用。从您链接的文档中:
After you have created a topic, either by subscribing client app instances to the topic on the client side or via the server API, you can send messages to the topic. If this is your first time building send requests for FCM, see the guide to your server environment and FCM for important background and setup information.
无法将消息从一台设备直接发送到另一台设备。为此,您将始终需要一个服务器(或其他受信任的环境)。有关更多信息,请参阅链接文档和:
我正在关注此 guide 以向某些设备发送消息。 关于构建发送请求的部分,它说:
// 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);
当我尝试导入消息 class 时,IDE 告诉我没有库,为什么?
也许它已被弃用但文档尚未更新?
谢谢
您复制的代码正在使用 Java 的 Firebase Admin SDK,无法在 Android 上使用。从您链接的文档中:
After you have created a topic, either by subscribing client app instances to the topic on the client side or via the server API, you can send messages to the topic. If this is your first time building send requests for FCM, see the guide to your server environment and FCM for important background and setup information.
无法将消息从一台设备直接发送到另一台设备。为此,您将始终需要一个服务器(或其他受信任的环境)。有关更多信息,请参阅链接文档和: