MrDroid MrDroid - 4 months ago 994
Android Question

How To Create Topic in FCM Notifications

I'm trying Firebase-Notification API the service is worked perfect when i send downstream message from console to app, but how to send message to topic registered users ?

i did in android side

FirebaseMessaging.getInstance().subscribeToTopic("TopicName");


but when i try send downstream message from console to topic it's says

This project does not have any topics


EDIT :
i figured out that after mapping the topic it's take up to 1 day to show up in Firebase Console

Answer

SOLUTION

First You need to create topic thorugh making POST request on

https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME

REPLACE

IID_TOKEN  -> WITH REGISTERATION TOKEN 
TOPIC_NAME -> WITH TOPIC-NAME YOU WANT CREATE

And to check your created Topics make a GET request on this URL

 https://iid.googleapis.com/iid/info/nKctODamlM4:CKrh_PC8kIb7O...clJONHoA?details=true

and insert your API_KEY in your Request HEADERS

Authorization: key=YOUR_API_KEY

and your topic will take up to 1 day to show up in firebase console so for testing you can make curl request or use a sofware like Advanced REST client