Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is FCM (firebase cloud messaging) Token for one device or for one account?

Tags:

I want to store FCM token in my android app user's table in database when user register to the app . When i want to send notification to specific user then i will fetch Token from corresponding row and send push notification.But i am confused that whenever app user logout from his app and register new account from same device ,then there will be two row and hence two Token for same device on database. How to handle such case? What happen to old Token in device? please anyone can help me??

like image 263
Roshan Sharma Avatar asked Jun 08 '16 05:06

Roshan Sharma


People also ask

Is FCM token unique per device?

Once acquired, it then needs to be saved to a datastore (e.g. an external database). When the time comes to send a message, the token is read from the datastore and a data payload is sent via FCM to the specific device with the token assigned. A messaging token is unique per device and application.

What is device token in firebase FCM?

On initial startup of your app, the FCM SDK generates a registration token for the client app instance. This is the token that you must include in targeted send requests from the API, or add to topic subscriptions for targeting topics.


2 Answers

The Instance ID token used to send FCM messages represents the instance of and app on a device. The current user of the app would not affect the token that represents the app instance. Uninstalling and reinstalling the app would cause a new token to be generated but not for in app behaviour like switching users.

You should still remove the mapping of the token to the user on logout and add a new mapping with the same token to the user that logs in but it will be the same token.

like image 101
Arthur Thompson Avatar answered Sep 26 '22 04:09

Arthur Thompson


I probably feel this may help you,

When user logs out clear his device token and make him Logout so that he won't be able to receive the updates and hence only one user at a time can get the updates

like image 3
Deepali-Systematix Avatar answered Sep 24 '22 04:09

Deepali-Systematix