【发布时间】:2022-01-15 03:39:46
【问题描述】:
我正在尝试使用带有 FireBase Admin SDK 的 Java 服务器向我的 Android 设备发送通知。
我可以从 FireBase 网站成功发送测试通知,但在我的服务器中的 Java 上设置它时遇到问题:
Message message = Message.builder()
.setNotification(Notification.builder()
.setTitle("$GOOG up 1.43% on the day")
.setBody("$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.")
.build())
.build();
// Send a message to the device corresponding to the provided
// registration token.
String response = "N/A";
try {
response = FirebaseMessaging.getInstance().send(message);
} catch (FirebaseMessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我收到此错误:
线程“main”java.lang.IllegalArgumentException 中的异常:必须指定令牌、主题或条件中的一个
我什至在哪里设置用户令牌?我只想使用 Java 中的 FireBase 向我的 Android FireBase 客户端发送一个简单的通知。
【问题讨论】:
-
@SkywalkerLukeJS 我认为我的代码没有解决方案。我正在尝试发送通知,而不是消息。那个人也在使用 NodeJS,而不是 Java。
标签: java android firebase push-notification