I've read all the documents of Firebase messaging,
but in my use case, I don't know how I should implement it...
In my use case :
The User can sign in at multiple devices.
Whenever an user has signed in at the specific device, the device should get notified when the user account receives any event.
This might be a little complex, but please take a look at the three situations below :

Each number of situation:
The lifetime of the User and the FirebaseInstance Token are different, so how could I make this? (I have a backend server to store the registration Id.) What's in my brain:
For 1 situation: To simply get the device token and save to the backend database.
For 2 situation: For this situation, I need to create a RegistrationToken table for saving multiple device's token with a relationship with User so that one user can own multiple registration tokens.
For 3 situation: Update the relationship to User B instead of User A if the token exists in the database.
But I think those solutions will be a hard work and uncommon, please tell me how do you solve this problem?
What I will suggest is that when you are registering a new user make a column in your database called token to store the firebase device id token.
So when the new user register you will get a new token assigned to its username.
Then with every login and log out attempts change the firebase id token.
This means that when ever someone will login from any device its token will be updated in database and when the user logout just pass null value to it hence you can ensure that users always get the right token according to usernames
Hope it helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With