In Firebase console, I saw the option to send a notification to User Segement with app "com.example" (where com.example is the app name).
As the image shows:
But how to do it from the server side using the FCM REST API:
In Firebase console, I saw the option to send a notification to User Segement with app "com.example" (where com.example is the app name).
As the image shows:
But how to do it from the server side using the FCM REST API:
Make a post call to https://fcm.googleapis.com/fcm/send with following parameters:-
Headers:-
Content-Type--application/json
Authorization--key={your server key}
Body:-
EDIT:-
Basically what you need to do is ,whenever u need to send notification you have to call this POST method from your server side and your app will automatically get a call in OnMessageReceived . You can handle that as:-
Subscribe your users depending on the OS
topic: "android" for android user
topic: "iOS" for iOS user
(or whatever name you want)
and then send to that topic...
You actually need to send a message to the topic .. All the members subscribed to a topic will get your message ..
Just check out the link ..
https://developers.google.com/cloud-messaging/topic-messaging
Unfortunately, it is not possible to send messages to User Segments using the FCM REST API.
As an alternative, you'll have to make use of the other ways to send messages to multiple devices, like simply using the
registration_ids
parameter and Topics Messaging (which I think is the most preferable for your use-case).Here are samples on how to send this using Postman or cURL.
i found a solution u can subscribe your app to a specific topic for example your app package name in your FirebaseInstanceIdService class so u can send data massage like
here is the code to subscribe your app to topic in FirebaseInstanceIdService class
its worked for me