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
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: