0

I'm following a tutorial for Cloud Messaging Messaging here https://firebase.google.com/docs/cloud-messaging/send-message#send_messages_to_specific_devices and I'm having trouble constructing the Message object.

When I try to send the message using the code below and run my app I am receiving the following compile error "Type mismatch: inferred type is Message but RemoteMessage was expected". It is telling me to pass a RemoteMessage instead of a Message but the send() parameter clearly states otherwise.

I'm also using the Firebase Admin SDK and finding it difficult to send a notification to a device programatically instead of the console notification composer. I really appreciate any help in advance!

     // See documentation on defining a message payload.
    val 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.
    FirebaseMessaging.getInstance().send(message)
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
dave o grady
  • 788
  • 8
  • 12
  • 1
    Are you trying to **send** a `RemoteMessage` from your Android app? If so: that is not possible. Also see https://stackoverflow.com/questions/57059108/cannot-resolve-symbol-com-google-firebase-messaging-message/57063431#57063431 – Frank van Puffelen Mar 08 '20 at 03:56

1 Answers1

0

You need to be using the RemoteMessage object

See here