3

Is there a way to obtain the list of clients who have registered for a particular topic in Firebase Cloud Messaging (FCM)?

I am planning to subscribe each client devices' location info as a topic. Later, when I want to get all devices in an area, I can just get a list of clients in that specific area. For example, clients in a sublocality 'Sharafiyah' can be listed under

    topics/SA/Jeddah/Sharafiyah
Mohammed Mukhtar
  • 1,731
  • 20
  • 18
  • What will you do with that list? store them to server or do some thing specific. If you can elaborate, we might provide a better solution. – Mohammed Atif Mar 04 '17 at 05:30
  • 3
    There is no public API to get the list of subscribers to a topic. See these similar questions and comments/answers: http://stackoverflow.com/questions/40851105/count-subscribers-of-a-topic-in-firebase-cloud-messaging/40861417#40861417 and http://stackoverflow.com/questions/39623742/firebase-cloud-messaging-check-existing-or-available-topics/39632704#39632704 – Frank van Puffelen Mar 04 '17 at 05:32

2 Answers2

3

For now, there is no provided solution to get the list of clients have registered to the specific topic in FCM. You have to create your own logic on the server to achieve your requirement to get list of clients registered for a topic.

But according to the below section

Get information about app instances

in the link Instance Id from developers site explains how to get list of topics are subscribed by a clients Instance ID.

Hope this will help you.

Anand
  • 857
  • 1
  • 12
  • 18
1

There is no way easy way to do this. The ONLY way is to already know all your users deviceIDs and scripting the retrieval of each users subscriptions there is no other way of doing this. Or from the beginning, as each user subscribes to a topic you save that data in your backend DB. It is a real pain. I wrote google a feature request regarding FCM Cloud Messaging Topic Management and this is the response I got from google:

We're aware that many developers, such as yourself, would like to have this topic management. There's actually an existing feature request regarding this. However, I can't provide any details or timelines as to when this will be available.

rolinger
  • 2,787
  • 1
  • 31
  • 53