How to get all topics list of Firebase through API

2020-02-28 04:21发布

问题:

I want to retrieve all the topics created so far via API request, similar to the list that firebase console display. See the image attached.

回答1:

There is no public API to get the list of topics for Firebase Cloud Messaging



回答2:

I just copy Answer from same question here becuase this page is first result in google: Get all subscribed topics from firebase cloud messaging

you can do it through a GET request

HTTP GET Request

https://iid.googleapis.com/iid/info/<TOKEN>?details=true
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

TOKEN in url : FirebaseInstanceId.getInstance().getToken();

key : can be found in [firebase console][1]: Your project -> settings -> Project settings -> Cloud messaging -> Server Key



回答3:

The way I got around this was using the firebase database, first create a topics folder inside the database, then add entries into this folder when a user creates a new topic.

You then create a function within the app to retrieve all entries in this folder within the database.

Now you can allow the user to select a pre existing topic from the results of the database and then use that to call your subscribe function.

Not a solid solution for all but worked for me.



回答4:

I too have a requirement for the exact same use case, However, I had to just make my own list in a datastore and read off of that. And not to forget that if I created a topic from code, I can't even see it until a couple of hours on the console. Hope there is an API soon to list topics and also decrease the lag in showing it on console.

So in cases where I can't really see it on console, I would have loved to see the list of topics API