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
This is an alternate path.
If you subscribe a client app to an unexisting topic then the topic will also be created without having to call any firebase url request.
It' will also take a couple of hours to appear on Firebase Console.
By using google shared example: https://github.com/firebase/quickstart-android/tree/master/messaging you can confirm the same.
FirebaseMessaging.getInstance().subscribeToTopic("news");
Log.d(TAG, "Subscribed to news topic");
First, given that IID_TOKEN
is your registration token and TOPIC_NAME
is the topic you want to create, you need to create topic by making a POST request to
https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME
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
Your topic will take up to 1 day to show up in Firebase console so for testing you can make curl request or use sofware like Advanced REST client
Firebase takes time to create new topic in console. In my case, new topic was created after 4 hours.
You can create a topic with http api:
https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME
1. IID_TOKEN = Device registration token, you can find it with following command on your android device :
String IID_TOKEN = FirebaseInstanceId.getInstance().getToken();
2.TOPIC_NAME = new a topic name
3.Authorization: key=YOUR_API_KEY. Set this parameter in the header. Look to screenshot:
Creating new topic via Advanced rest client
YOUR_API_KEY:
console.firebase.google.com
and send request and you will be receive http status "OK".
Then you can get infos about all your topics in your current project with following api :
https://iid.googleapis.com/iid/info/IID_TOKEN?details=true
here need add Authorization key to header of request and you will be receive your topics list: response info topics
I recommend read this article about Instance ID/Server by Google