【发布时间】:2020-09-14 16:21:06
【问题描述】:
无法向 Android 设备发送 Firebase fcm 推送通知。
当我从 firebase 控制台发送测试消息时,它会发送到设备。所以 Android 端代码运行良好。
对于后端 Java 服务器,我使用的是 firebase sdk
public void sendNotification2(String notification, String title, String to) {
String registrationToken = to;
Message message = Message.builder().putData("score", "850").putData("time", "2:45")
.setToken(registrationToken).build();
String response;
response = FirebaseMessaging.getInstance().send(message);
System.out.println("Successfully sent message: " + response);
}
代码输出:成功发送消息:projects/myappname/messages/0:1590590793114288%9cceaf10deffd7abc
但是设备没有收到通知。
【问题讨论】:
标签: java firebase server push-notification firebase-cloud-messaging