如何在 FCM 通知中创建主题 [英] How To Create Topic in FCM Notifications
问题描述
我正在尝试 Firebase-Notification API,当我从控制台向应用程序发送下游消息时,该服务运行良好,但如何向主题注册用户发送消息?
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 ?
我在安卓方面做过
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
我发现在映射主题后最多需要 1 天才能显示在 Firebase 控制台中
EDIT : i figured out that after mapping the topic it's take up to 1 day to show up in Firebase Console
推荐答案
首先,假设 IID_TOKEN
是您的注册令牌,而 TOPIC_NAME
是您要创建的主题,您需要通过向
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
要检查您创建的主题,请对该 URL 发出 GET 请求
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
并在您的请求 HEADERS 中插入您的 API_KEY
and insert your API_KEY in your Request HEADERS
Authorization: key=YOUR_API_KEY
您的主题最多需要 1 天才会显示在 Firebase 控制台中,因此为了进行测试,您可以发出 curl 请求或使用诸如 高级 REST 客户端
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
这篇关于如何在 FCM 通知中创建主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!