<分区>
有人问过类似的问题here但没有得到答复。 我正在尝试使用 FCM 并使用官方 Firebase 示例中提到的代码向设备发送设备通知 from github :
public void sendToToken() throws FirebaseMessagingException {
// [START send_to_token]
// This registration token comes from the client FCM SDKs.
String registrationToken = YOUR_REGISTRATION_TOKEN;
// See documentation on defining a message payload.
Message message = Message.builder()
.putData("score", "850")
.putData("time", "2:45")
.setToken(registrationToken)
.build();
// Send a message to the device corresponding to the provided
// registration token.
String response = FirebaseMessaging.getInstance().send(message);
// Response is a message ID string.
System.out.println("Successfully sent message: " + response);
// [END send_to_token]
}
但是在运行应用程序时,我收到此错误:
error: incompatible types: Message cannot be converted to RemoteMessage