I am trying to make push notifications using FCM in which any user subscribed to the topic "Alerts" can send a notification to others. I can recieve notifications sent using the FCM testing system. But when I was reffering to the documentation for sending push notifications, it gave me this code
String topic = "highScores";
// See documentation on defining a message payload.
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.
String response = FirebaseMessaging.getInstance().send(message);
// Response is a message ID string.
System.out.println("Successfully sent message: " + response);
I had 2 problems in this
First, the class named message does not exist. After much research, I found out the message class was deprecated and RemoteMessage had to be used but the RemoteMessage documentation had no proper instructions on how to do this.I need help in that
Second, a very small problem but does the topic name have to be the channel name or the topic to which everyone is subscribed to?
Even sending the message to a list of tokens will be perfect