Is there a way to create a registration id with scope of logged in user. I have an app which allows user to login as different user (say one user as student and other as a parent). User can switch between the users. Case is somewhat similar to gmail app where multiple email ids can be logged in at same time.
The issue is when we call
FirebaseInstanceId.getInstance().getToken()
It will give the device id for that app instance. So if i am to target a specific user logged in i cannot.
One way i can accomplish targeting a user is to send user_id
explicitly as data, which in my case is not efficient as it will take to send one FCM send request for each user. Is there anyway this can be accomplished. Would like to know how gmail is handling user specific notifications.
Token (reg id) is intended to represent a mobile device.
As you've said you can send in payload or in tags which user the push notification is destined to, check if it is the same as the current logged in user and decide whether to create the notification or not.
The only problem here may be, how to identify the current user if at the moment of push arrival your application is killed or all users are logged out. I think in this case the solution depends on privacy level of the pushed data.
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