Can i send push notification to topic using FirebaseMessaging.getInstance().send
?
There are a lot of answers describing how to do this using https request. It's clear, but I don't want to use large block of code, building JSON request body, adding custom headers with my key, etc.
So, what I have tried:
At first - FirebaseMessaging.getInstance().subscribeToTopic("test")
then
RemoteMessage rm = new RemoteMessage.Builder("test")
.addData("message", "Hello")
.build();
FirebaseMessaging.getInstance().send(rm);
where test
is my topic.
Result: no message received. But when I send this JSON via postman:
{"to": "/topics/test",
"data": {
"message": "Hello",
}
}
everything is OK and i receive notification on my phone.
So, do FirebaseMessaging.getInstance().send
support sending topic messages and how do i need to configure RemoteMessage
?