FCM registration generates a registration token that is associated with the device and not a particolar user. So, how to handle two common scenarios:
- Logout: A logged in user is supposed to receieve notification, until he logs out
- Switch user: If after logging out a new user logs in, it should have a different registration token that does't interfeer with the previous one.
This is an old documentation (from GCM)
Developers should never unregister the client app as a mechanism for logout or for switching between users, for the following reasons:
A registration token isn't associated with a particular logged in user. If the client app unregisters and then re-registers, the app can receive the same registration token or a different registration token.
Unregistration and re-registration may each take up to five minutes to propagate. During this time messages may be rejected due to the unregistered state, and messages may go to the wrong user.
Of course GCM now is deprecated, but it is likely that the same rules described here applies.
So, what are the possible ways for handling the two aforementioned scenarios? I could not find anything in the documentation.