【问题标题】:GCM not documented responseGCM 未记录响应
【发布时间】:2015-11-12 07:26:35
【问题描述】:

registration_id 被列入黑名单时,我收到了奇怪的 GCM 响应 有效载荷是

{"data":{"title":"Your troopers were attacked"},"registration_ids":["BLACKLISTED"]}

回复是

{"multicast_id":9151224166188989772,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidParameters"}]}

响应头是

   [headers] => Array
    (
        [content-type] => application/json; charset=UTF-8
        [date] => Thu, 12 Nov 2015 04:16:06 GMT
        [expires] => Thu, 12 Nov 2015 04:16:06 GMT
        [cache-control] => private, max-age=0
        [x-content-type-options] => nosniff
        [x-frame-options] => SAMEORIGIN
        [x-xss-protection] => 1; mode=block
        [server] => GSE
        [alternate-protocol] => 443:quic,p=1
        [alt-svc] => quic=":443"; p="1"; ma=604800
        [accept-ranges] => none
        [vary] => Accept-Encoding
        [transfer-encoding] => chunked
    )

[http_version] => HTTP/1.1
[status] => 200
[message] => OK

我在文档 https://developers.google.com/cloud-messaging/http-server-ref#table9 中找不到此类错误。有谁知道这个错误是什么意思?

对于任何其他registration_id,例如“GOOGLE”,我得到了正确的响应InvalidRegistration

【问题讨论】:

  • 哪个客户端应用发出了设备端注册请求?您是否使用模拟器进行注册?
  • 没关系 :) 我知道这不是有效的 GCM 令牌(例如来自模拟器),我也没有任何模式可以在服务器端验证令牌(stackoverflow.com/questions/33355586/…)。但我不知道如何在服务器端处理此类错误 InvalidParameters,例如 - 是否需要从数据库中删除此类设备。谢谢!
  • 实际上,如果我们知道特定的模拟器导致注册错误,这有助于排除故障。

标签: google-cloud-messaging


【解决方案1】:

我假设 'BLACKLISTED' 是保留字。谷歌提到你不应该使用保留字,但没有给出完整的列表。

这是基于阅读 https://developers.google.com/cloud-messaging/http-server-ref 的猜测,其中提到了这一点......

密钥不应是保留字(“from”或任何以“google”或“gcm”开头的字)。请勿使用此表中定义的任何字词(例如 collapse_key)。

【讨论】:

    猜你喜欢
    • 2014-02-06
    • 2016-09-28
    • 2016-09-02
    • 2021-06-12
    • 2017-12-18
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多