I have a web app that persists a user ID and firebase notification token per user. The user and token is created on Android device and send to the server, so server knows where to send notifications (because of the token).
The issue here is, that one user can be logged in on multiple devices. If the user is on two devices, then I should send notification to both devices. The web app knows 2 tokens for the one user ID. That is OK.
But what if I uninstall and install the application on the same device. I get a new token for the user, so I save it to web app, but then I have 3 tokens for one user ID. That is not correct as I should have only 2 tokens (the one token is OLD).
I know that I can save the DEVICE ID too (UUID), so I know that on that one device the token has been changed, so I can delete the old one for the device. BUT that for Android SDK 23 and higher I need to ask for a special permission to read the UUID. But I do not want to bother the users to ask for the permission to access UUID.
So I have the problem here. I want to keep only VALID tokens for the one user ID on my web app (if the user has 2 phones, then I should keep only 2 tokens for the user), but I do not know how without users accepting the permission.
Please help me here, I really could not find the standard solution and answer for this :( I guess there is some standard solution.
Thanks!