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:
https://fcm.googleapis.com/fcm/send
Push notifications are messages that pop up on a users device. A user can see these notifications without having to be on the app. This is important for users retention. WHAT WE ARE BUILDING.
Configuring OneSignalYou need to configure OneSignal for each of the mobile platforms it will be working on. Once your configuration is done, you'll have an Application ID and a REST API KEY from OneSignal. You can configure OneSignal for iOS and Android.
Create a google API project. Enable push notifications for the project and get a API key. Get a registration ID through android app (each device has a registration ID for a specific application) Create a server application to send your push messages as push notifications through google servers by GSM.
Let's have a look at a notification payload: Whenever there is a title and body in your notification, the system will handle it for you in the background. When there's data in your payload and you click the notification, you're able to handle it in your service.
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
{
"to" : "/topics/your_package_name",
"data" : {
"key1" : "value 1",
"key2": "value 2",
...
}
}
here is the code to subscribe your app to topic in FirebaseInstanceIdService class
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService
{
private final String TAG="your_tag";
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
FirebaseMessaging.getInstance().subscribeToTopic("your_app_package_name");
}
}
its worked for me
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