如何在FCM通知中创建主题

如何在FCM通知中创建主题

本文介绍了如何在FCM通知中创建主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Firebase-Notification API,当我从控制台向应用发送下游消息时,该服务正常工作,但如何将消息发送给注册用户?



我在android方面做了$ / $>
$ b $ pre $ FirebaseMessaging.getInstance()。 subscribeToTopic( TopicName);

但是当我尝试从控制台向主题发送下游消息时,它说

 该项目没有任何主题



i计算出来后,映射的话题需要花费1天才能显示在Firebase控制台中

解决方案

首先,假设 IID_TOKEN 是您的注册标记,并且 TOPIC_NAME 是您要创建的主题,您需要
$ b

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

要检查您创建的主题, GET 请求

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

并将您的API_KEY插入您的请求标题

  Authorization:key = YOUR_API_KEY 

您的主题将占用1天在Firebase控制台中显示,以便进行测试,您可以进行卷曲请求或使用软件,如


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

解决方案

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

这篇关于如何在FCM通知中创建主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 14:31