How to get all topics list of Firebase through API

2020-02-28 04:49发布

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.

enter image description here

4条回答
孤傲高冷的网名
2楼-- · 2020-02-28 05:02

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

查看更多
Summer. ? 凉城
3楼-- · 2020-02-28 05:08

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

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2020-02-28 05:14

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

查看更多
我只想做你的唯一
5楼-- · 2020-02-28 05:16

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.

查看更多
登录 后发表回答