GCM:您如何为设备订阅主题?

GCM: How do you subscribe a device to a topic?

Android app/device 可以调用 PubSub subscribe() 订阅主题。

是否可以使用 GCM 的 HTTP API 订阅和取消订阅带有注册 ID 的设备?非常感谢示例或参考。

已编辑: 是的,正如@Asaf 提到的,您可以通过这个 API 调用来做到这一点: https://iid.googleapis.com/iid/v1/IID_TOKEN/rel/topics/TOPIC_NAME

这是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.