GCM:您如何为设备订阅主题? [英] GCM: How do you subscribe a device to a topic?

查看:124
本文介绍了GCM:您如何为设备订阅主题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个Android应用/设备可以调用PubSub subscribe()来订阅一个主题。

是否可以订购和取消订阅一个设备的注册ID为使用GCM的HTTP API的主题?一个例子或引用将不胜感激。

解决方案

编辑: @Asaf提到,您可以通过以下API调用完成此操作:
https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME



以下是 doc $ b


<给定注册令牌和支持的关系,您可以
创建映射。例如,您可以通过调用
此端点上的Instance ID服务来订阅应用程序实例到
Google云消息传递主题,从而提供应用程序实例的令牌,如下所示:



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



参数
<授权:key = YOUR_API_KEY。在标题中设置此参数。



An Android app/device can call PubSub subscribe() to subscribe to a topic.

Is it possible to subscribe and unsubscribe a device with its registration id to a topic using GCM's HTTP API? An example or reference would be greatly appreciated.

解决方案

Edited: Yes, as @Asaf mentioned, you can do that via this an API call: https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME

Here is the doc

Given a registration token and a supported relationship, you can create a mapping. For example, you can subscribe an app instance to a Google Cloud Messaging topic by calling the Instance ID service at this endpoint, providing the app instance's token as shown:

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

Parameters

Authorization: key=YOUR_API_KEY. Set this parameter in the header.

这篇关于GCM:您如何为设备订阅主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆