5

Suppose a FCM token is generated abcd and assigned to a user say user 1 now this token is no longer associated to user 1 as he uninstalled his app. Can this token abcd be assigned to some other user in future?

EDIT 1:

I know it is unique at a time. But if a token is not being used by anyone abcd will that be used again by some other user as it is still unique as user 1 is using a different token?

EDIT 2:

The token I am referring to is the device regestration token.

Shashank Singh
  • 647
  • 1
  • 5
  • 22

2 Answers2

2

The simple is NO

Google/Firebase practice is having a hashing algorithm to generate a long and non repeating id (usually associate with timestamp and other factors), which usually can be up to 20 characters or more, to ensure it is unique in the database (FCM device token db).

Therefore, it will always assign a new and unique token to the new device. Won't reuse the token in any circumstances.

[UPDATE]

Thanks for your comment, now I have a concrete answer to your problem now. Each token contains the particular user meta-data, and other info including unique id etc.

So the token can only be revoked by the same user but cannot be use by others (because it contains the user meta-data).

Angus
  • 3,680
  • 1
  • 12
  • 27
  • Thank you so much. I just need to know the Source before accepting the answer. – Shashank Singh Aug 29 '18 at 10:05
  • According to [this answer](https://stackoverflow.com/a/54853590/6744473) FCM registration tokens aren't associated with users at all, they are associated with app instances on specific devices. And perhaps the FCM page linked above has been changed since it was added, but there's nothing there to suggest that there's any user meta data associated with FCM registration tokens. – shoe Jan 23 '22 at 07:17
  • Although I think it's important to note that despite that _maybe_ a given token won't be issued more than once for a given application, that doesn't necessarily mean that the possibility that a user being assigned a preexisting registration token should not be dealt with. As because they are associated with app instances and not users, a user could log out and a different one log in, and the FCM registration token will be the same as it was for the other because the app instance is still the same. – shoe Jan 23 '22 at 07:22
  • If there is no logic that takes that into account, you could end up sending push notifications to the old user using their last known FCM registration token, but what ends up happening is that the new user ends up being the one that receives them because they're the one that happens to be logged into the app instance associated with that token at the time the push notification is sent. – shoe Jan 23 '22 at 07:27
0

The documentation about GCM says that token is unique, I think the same applicable for FCM as well. https://developers.google.com/cloud-messaging/registration

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

Sergey Zabelnikov
  • 1,855
  • 1
  • 14
  • 24
  • I agree it is `unique` at a time. But if a token is not being used by anyone `abcd` will that be used again by some other user as it is still unique as `user 1` is using a different token? – Shashank Singh Aug 29 '18 at 06:36