0

Firebase documentation clearly specifies steps to send notification to device groups. It mentions that:

Create the notification_key, which identifies the device group by mapping a particular group (typically a user) to all of the group's associated registration tokens

Does it mean that notification_key is unique for the the device group? Docs do not mention that anywhere explicitly. I wanted to be doubly sure, as add and remove devices to group POST calls return notification_key in response making me think that it can change!

At the moment I was persisting notification_key once in DB right after group creation and using it for all subsequent requests. Is it the correct approach?

Richeek
  • 2,068
  • 2
  • 29
  • 37

1 Answers1

1

A device group notification_key is expected to be unique similar to how registration tokens are.

It is the right approach to store the notification_key as soon as possible. What is actually advised is to also make use of the notification_key_name:

The notification_key_name is a name or identifier (e.g., it can be a username) that is unique to a given group. The notification_key_name and notification_key are unique to a group of registration tokens.

A group doesn't become a new group just because a member is added or removed -- hence it should return the same key.

AL.
  • 36,815
  • 10
  • 142
  • 281
  • So does it also mean that `notification_key` does not change ever? Playing devil's advocate, my concern was say the key 'A' which was unique, changed to a unique key 'B' – Richeek Sep 14 '17 at 05:15
  • It won't. I think it wouldn't be much of a useful *key* if it constantly changes. Make use of the `notification_key_name`, it would be like a *two-variable-verification* -- key and alias. – AL. Sep 14 '17 at 05:28
  • Gotcha thanks! BTW on a separate note do you know if the API mentioned here is still valid (to fetch notification_key from notification_key_name): https://stackoverflow.com/questions/42568632/is-there-a-way-to-retrieve-an-existing-notification-key-based-on-a-registration – Richeek Sep 14 '17 at 06:03
  • You're welcome. Yup. The InstanceID API is currently available. – AL. Sep 14 '17 at 06:46