Assuming that one has created a device group in Firebase Cloud Messaging, is there a way to retrieve an existing notification_key
for a device group after it's been created?
Is there a way to look up the notification_key
based on either notification key name or by registration id?
It seems the notification key is only returned on the create method and if the key is ever lost or errors on saving to the the database - it would be impossible to add another registration id to the the key name without a notification_key
since it already exists.
You can retrieve the notification_key for a device group if you know the notification_key_name that was used when you created it. Ref: https://firebase.google.com/docs/cloud-messaging/android/device-group
Use this:
https://android.googleapis.com/gcm/notification?notification_key_name=your-key-name
Ref: https://groups.google.com/forum/#!topic/firebase-talk/ytovugx8XNs
For example:
let options = {
url: 'https://android.googleapis.com/gcm/notification?notification_key_name=the_name',
method: 'GET',
headers: {
"Content-Type": "application/json",
"Authorization": "key=" + authorizationKey,
"project_id": projectId
}
};
request(options, function (error, response, body) {
if (!error) {
res.json(body);
}
else {
res.json(error);
}
});
One thing I found when using this call was that the notification_key returned was always different, but I was able to use it successfully to add or remove registration_ids.
I'll add some additional information from comments I made earlier:
There is currently no API to retrieve the Device Groups (notification_key
s) associated with a given Registration Token. AFAIK, managing/mapping relationships of Device Groups and its associated registration tokens are the developers responsibility.
For your scenario, I would suggest to temporarily store the notification_key
until it is successfully stored in your App Server.
Some possibly helpful posts:
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