How To Create Topic in FCM Notifications

后端 未结 4 2123
小蘑菇
小蘑菇 2020-11-28 19:51

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 ? <

4条回答
  •  温柔的废话
    2020-11-28 20:33

    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

提交回复
热议问题