A similar question has been asked here but it got no answer. I am trying to send device to device notification using FCM and using the code mentioned in the official Firebase sample 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]
}
But while running the app, I'm receiving this error :
error: incompatible types: Message cannot be converted to RemoteMessage