【发布时间】:2014-06-20 16:42:49
【问题描述】:
作为使用 GCM 接口的一部分,服务器需要使用这种格式才能将消息发送到 GCM 服务器(将数据传递给设备):
headers = { 'Content-Type' : 'application/json', 'Authorization': 'key=' + GCM_KEY }
values = { 'registration_ids': [regId], 'data': {'msg': 'helo'} }
其中:GCM_KEY 是我的服务器密钥,regId 是由“,”分隔的注册 ID 字符串。
假设用户 A 的注册 ID 为 1,用户 B 的注册 ID 为 2。
当我尝试仅向一个设备(例如用户 A)发送消息时,regId 等于字符串“1”并且消息正确传递。当我尝试仅将消息传递给用户 2 时,也会发生同样的情况。
但是当我尝试将消息发送到两个设备时,regId = '1,2',消息就不会通过(根据 GCM 文档,成功是响应包含 0 个失败和 0 个 canonical_ids,所以我得到的结果与成功的响应不同)。
有什么想法吗?
【问题讨论】:
标签: android google-app-engine google-cloud-messaging