I want to send notifications to all the android devices within my app. Actually, I can send a notification to a single token and it looks like this:

{
    "to": "dwh6BFzxAOE:APA91bFenA-tySAKuNtiJGCeULewqYOwRDwfZMe4hWGN10Gx2S3sEoArZOvn_0pQihsDOtx6upcmwBbrTT2gG-rpYmPmXOvuzqMRoZy_rM6xCPyviXIn-JAAtoEEq2S4wEtGgnOBLR41", 
    "notification": {
        "title": "My title",
        "body": "This is the message"

    }
}

But I don't understand how to send this notification to all devices at once. Without subscription.

I am using flutter for the apps, and I have created a react js web service to call this API REST and POST notifications.


Solution 1: RoboBear

To achieve Push Notifications via Firebase, you need to implement FireBase Cloud Messaging to push notifications to devices.

From the docs,

An FCM implementation includes two main components for sending and receiving:

    A trusted environment such as Cloud Functions for Firebase or an app server on which to build, target, and send messages.
    An iOS, Android, or web (JavaScript) client app that receives messages via the corresponding platform-specific transport service.

See the documentation for server setup, or you can also use FireBase Functions. It sounds like you want to integrate Firebase Functions with Cloud Messaging. I haven't done this before, but here is a blog post doing this for a Flutter Web project:

https://medium.com/@umeshnalinde7/flutter-cloud-messaging-with-firebase-functions-firestore-android-175904a15537