On the Firebase doc, it always has a "to" field with a device/token id... but how can I get it to send the notification to all devices. What do I replace the to field with, or what value do I put in there. I'd removed it altogether but it comes back with an error asking for it. Any ideas?
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data" : {
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
},
}
Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.
As Frank van Puffelen said there isn't a way to send to all devices. What you could do is to subscribe everyone to a single topic in the app side using:
FirebaseMessaging.getInstance().subscribeToTopic("TopicName");
So your message would look like this:
{
"to" : "/topics/TopicName",
"data" : {
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
},
}
The topic is automatically created in the Firebase server side, but sometimes it takes a while to show up in the Firebase drop down list.
The number of users in a single topic are unlimited.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With