Search code examples
androidfirebasefirebase-authenticationfirebase-cloud-messagingfirebase-notifications

Integrate firebase notifications topics and firebase authentication


I am currently using the firebase notifications console to send notifications to specific android devices using topics. Is it possible to link the topics that the device is subscribed to with the user account that is logged in through firebase authentication.

Ideally I want it so that the when the user logs in, a request can be sent to determine all the topics the user was previously subscribed to on a different device and subscribe to the same topics on this device. Similarly when the user logs out, the device should unsubscribe from all the topics.

I would prefer if this could be done without having to write any server side code.


Solution

  • There is no automatic mapping of authenticated user and subscribed topics. However you can do this mapping yourself via the Firebase Realtime Database. When a user subscribes to a topic you can add an entry to the FRD and when that user signs in on another device you can check the FRD and automatically subscribe the user to the required topics.