Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User Notifications - How to recover a lost notification_id from GCM?

I generate notification_keys as described here.

Suppose that due to some error I fail to store it, so I try to re-register.
This time I receive a 400 error with the message "notification_key already exists".
This looks odd, especially compared to registration of a device to GCM, where you can register as many times as you want and always get the same Registration ID with status 200.
Now I can't register again, and I also can't unregister, because I don't have the notification_id.

Is there any way to get the previously generated notification_key from GCM?
Or is the only way to register again with a different notification_key_name?

like image 374
mat Avatar asked Oct 22 '14 15:10

mat


1 Answers

I can't find any documentation about it but it's now possible to recover a notification_key for a device group by doing a GET request to https://fcm.googleapis.com/fcm/notification?notification_key_name=my_notification_key_name with the headers they require: Authorization: key=my_key, Content-Type: application/json and project_id: my_id.

You will get a response like { "notification_key": "lost_key" }

But be aware that returned notification_key is not the same as original, but you can use both of them.

like image 95
Zalastax Avatar answered Dec 04 '22 23:12

Zalastax