将设备组 (notification_key) 订阅到主题 [英] Subscribe a Device Group (notification_key) to a Topic

查看:17
本文介绍了将设备组 (notification_key) 订阅到主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到了这个 帖子,其中的一般想法是如何为用户订阅一个主题,其中包含多个设备.我提供了一个 answer,建议使用设备组,然后执行 batchAdd 在服务器端.

I've recently encountered this post where the general idea is how to subscribe a user to a topic, with multiple devices. I provided an answer, suggesting to make use of the Device Group, then doing the batchAdd on the server side.

但我想知道是否可以使用设备组 notification_key 订阅主题?

But I was wondering if it was possible to subscribe to a topic using the device group notification_key?

我没有在文档中看到任何提到类似内容的内容.通知密钥在 doc 中描述为:

I haven't seen anything that mentions something like that in the docs. The notification key is described in the doc as:

组中的所有设备共享一个公共通知密钥,这是 FCM 用来将消息扇出到组中所有设备的令牌.

All devices in a group share a common notification key, which is the token that FCM uses to fan out messages to all devices in the group.

所以我想也许可以使用它.但是找不到任何提到它的东西.我在社区中查看了任何其他类似的帖子,浏览了文档,但其中大部分只是关于为单个设备订阅一个主题.

So I thought maybe it was possible to use it. But can't find anything that mentions it though. I've looked around the community for any other similar posts, went through the docs, but most of it are just about subscribing a single device to a topic.

我对帖子的回答是一个好方法吗?还是我只是错过了一些已经有关于如何实际执行此操作的流程/流程的内容?

Was my answer to the post a good method? Or did I just miss something where there is already a process/flow on how to actually do this?

我自己还没有真正尝试过,但这是我能想到的唯一方法.我还在学习 GCM &如果之前尝试过 FCM 的人能对此有所了解,我将不胜感激.

I haven't really tried it out myself, but it was the only way I could think of. I'm still studying about GCM & FCM and I would appreciate it a lot if someone that tried it before can shed some light about this.

推荐答案

您不能为 device_group 订阅主题.实现这一点的方法是将与设备组关联的令牌单独或批量订阅到主题.

You cannot subscribe a device_group to a topic. The way to achieve this would be to subscribe the tokens associated with the device group to the topic either individually or in batch.

这篇关于将设备组 (notification_key) 订阅到主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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