From FCM documentation here tells me how to send message to a device group, so I've to send something as followed:
https://android.googleapis.com/gcm/notification
Content-Type:application/json
Authorization:key=API_KEY
project_id:SENDER_ID
{
"operation": "create",
"notification_key_name": "appUser-Chris",
"registration_ids": ["4", "8", "15", "16", "23", "42"]
}
However, I don't found there is any clear explanation told me how to get "registration_ids"
from Firebase FCM.
I could only get "registration token" using FirebaseInstanceId.getInstance().getToken()
.
So anyone can tell me how to get "registration_ids"
please?
The registration_ids parameter refers to the Registration Tokens you want to add in that specific Device Group. Described as: An ID generated by the FCM SDK for each client app instance. Required for single device and device group messaging. Note that registration tokens must be kept secret.
"registration_ids"is an array of the registration tokens acquired by calling FirebaseInstanceId.getInstance().getToken()on a device. If you put multiple registration tokens in the array, the same push notification will be sent to each.
To retrieve a Firebase installation ID: Firebase services can authenticate Firebase installations with auth tokens retrieved from FIS. For example, when designing A/B tests for Remote Config, you can authenticate a targeted test device using an installation auth token.
Until Firebase notifies the client app, some of the app's services might still target the ID—for example, a Firebase installation might continue to receive FCM notifications for a few hours.
To register, open the Firebase console. You'll be asked to enter your project name and accept all terms. Once you've successfully created your project, you will see the project overview page on which you can select which platform your application is.
"registration_ids"
is an array of the registration tokens acquired by calling FirebaseInstanceId.getInstance().getToken()
on a device. If you put multiple registration tokens in the array, the same push notification will be sent to each.
If you only want to send a notification to one device with a registration_id
of 4
, your "registration_ids"
array need only contain one value like so: "registration_ids": ["4"]
If you want to send a notification to multiple devices, call FirebaseInstanceId.getInstance().getToken()
on each device to get the token then populate the array with values like you already have.
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