Search code examples
firebasefirebase-cloud-messaging

Are Firebase Cloud Messaging (FCM) tokens unique?


I can't find any place in firebase docs, where indicated that received tokens are unique. I will be grateful if someone could point me such place. Main question - should I make unique constraint in database for such tokens. Thx!


Solution

  • When I search for Are Google Cloud Messaging tokens unique, the first result is this page from the documentation, which says:

    To verify that they can send and receive messages, client apps must register with GCM. In this process, the client obtains a unique registration token...

    Firebase Cloud Messaging Instance ID Tokens uniquely identify an instance of an app. They are globally unique.

    Whether you should mark the column in your database as unique depends on your usage of that column. As yourself questions like: what bad thing will happen if a token is present twice in this table? Will marking the column unique prevent the bad thing from happening?