Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 583
Compadre Avatar asked Apr 25 '17 14:04

Compadre


4 Answers

According to documentations, they're unique, but you can't bind them to a specific device since they might change.

Documentation for IOS:

The registration token may change when:

  • The app is restored on a new device
  • The user uninstalls/reinstall the app
  • The user clears app data.

Documentation for Android:

The registration token may change when:

  • The app deletes Instance ID
  • The app is restored on a new device
  • The user uninstalls/reinstall the app
  • The user clears app data.
like image 127
farzadshbfn Avatar answered Sep 29 '22 11:09

farzadshbfn


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?

like image 23
Frank van Puffelen Avatar answered Sep 29 '22 09:09

Frank van Puffelen


As per my experience I have noticed that the FCM token is changed in three scenario they are as follows:-

  1. When the application is uninstalled or reinstalled.
  2. When the data of the application is cleared.
  3. When the application is installed in new device.

Note:- There is no way to keep the FCM token same.

like image 33
sarhan bax Avatar answered Sep 29 '22 10:09

sarhan bax


Yes, they are unique but they are not constant. Means for first time when I had installed one application then FCM token was let's say abcd but when I uninstalled the app and again installed the same app then my FCM token was not abcd but something else.

So, FCM tokens are unique but they are not constant, they keep on changing when we uninstall and install the application.

like image 34
Israr Avatar answered Sep 29 '22 10:09

Israr