Get all subscribed topics from firebase cloud messaging

I have searched Android API, asked questions for the same on SO but din't find anything. There is nothing in Android API to get all topics of a specific token.

However, 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=AAA....i1nM:APA9.....81gTPXCE55....JLPEG0wZobG_ile8lI35JTzHYE5MC..BmDD_Cxj5OxB1Yh....Rs5lo3UwLNL9h-WcocGV....b5bYWNI55kzNsrHK-7GljUDtMn 

TOKEN in url : FirebaseInstanceId.getInstance().getToken(senderId, scope);

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

Note: Be careful when finding key, dont use web api key its different.

senderId can be found in Settings -> Cloud Messaging -> Sender ID

scope is usually "FCM"


Never tried programmatically.

But you can do it by goto firebase console->your project->cloud messaging->new notification->target-> click on topic tab next to user segment just click on Message topic text box you will get list of subscribed topics

enter image description here


For those that would like to test it with command line CURL follow bellow the syntax that I have used:

#curl --location --request GET 'https://iid.googleapis.com/iid/info/yourFCMDeviceToken?details=true' \
--header 'Authorization: Bearer YourProject_CloudMessaging_ServerKey'

Response:

{
    applicationVersion: '4194309',
    application: 'com.domain.app',
    scope: '*',
    authorizedEntity: '913674269572',
    rel: { topics: { topicName: { addDate: '2020-08-19' } } },
    appSigner: 'ae7cbSomeHash23jsdfff34ac7ffd',
    platform: 'ANDROID'
}