Using the new FirebaseMessaging it's easy to un/subscribe to topics via:
FirebaseMessaging.getInstance().subscribeToTopic();
FirebaseMessaging.getInstance().unsubscribeFromTopic();
But is there any way to get all topics the current installation is subscribed to ?
Subscribe the client app to a topic Client apps can subscribe to any existing topic, or they can create a new topic. When a client app subscribes to a new topic name (one that does not already exist for your Firebase project), a new topic of that name is created in FCM and any client can subsequently subscribe to it.
When your app is in the background, Android directs notification messages to the system tray. A user tap on the notification opens the app launcher by default. This includes messages that contain both notification and data payload (and all messages sent from the Notifications console).
Maximum message rate to a single device For Android, you can send up to 240 messages/minute and 5,000 messages/hour to a single device.
Using Firebase Cloud Messaging, we can send three types of messages, i.e., Notification Message, Data Message, and the message with both Notification & Data Payload.
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.
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"
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'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With