Is FCM (firebase cloud messaging) Token for one de

2019-01-19 11:08发布

问题:

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

回答1:

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.



回答2:

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