0

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.

1 Answers1

0

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.

Arthur Thompson
  • 9,087
  • 4
  • 29
  • 33
  • Thanks for the answer. My worry is if for some reason the database becomes out of sync with the topics subscribed by the device. Is there a method I can call that will retrieve all the topics subscribed by the device at the given point of time which I can then use to verify the values stored in the database. – Varun Varma Jun 08 '16 at 14:55
  • You can set up database listeners on the devices so they can subscribe and unsubscribe as necessary when the database changes. – Arthur Thompson Jun 08 '16 at 16:54