【问题标题】:GCM Error=MissingRegistration sending messages via JSONGCM Error=MissingRegistration 通过 JSON 发送消息
【发布时间】:2014-04-24 12:53:07
【问题描述】:

我正在通过 Fiddler 测试推送 GCM

标题:

User-Agent: Fiddler
Authorization: key=AIzaSyAkXfcuLLCZ-5n18wwO6XeJ13g-z9ja
Host: android.googleapis.com
Content-Length: 286

正文:

{"registration_ids":["APA91bHyn8YHcH_vSuOo7_A0PMgF5SU1K0FebOFGKXYTqpN5x4eD0tVBvzQLn749TVcczN5gSjB1wqf5AzYfxFI_qskA1Nzipf-9MfdEom1PI1vkFqKIg9B8vZvPLOLozE7jaRzELuyDzpFRbO3Xh5lT-KDA"],"collapse_key":"8b990f5a-78fc-4bad-b242-ffc740a750fb","data":{"message":"message to device"}}

我有一个错误

Error=MissingRegistration

我的问题在哪里? 所有的 id 都是正确的。

【问题讨论】:

  • 您应该删除私人数据,例如密钥和秘密 ID

标签: android json push-notification google-cloud-messaging


【解决方案1】:

斯威夫特 5

In my case receiver token was missing and after put the fcm receiver token its work fine for me

【讨论】:

    【解决方案2】:

    对于 Firebase,您可以从 https://firebase.google.com/docs/cloud-messaging/http-server-ref#error-codes 获取信息

    检查请求是否包含注册令牌(在 registration_id 在纯文本消息中,或在 to 或 JSON 中的registration_ids 字段)。

    【讨论】:

      【解决方案3】:

      对于新的云消息,当你想从服务器发送一个dwonstream消息时,你需要使用“to”来声明目标注册id。

      如下:

      https://gcm-http.googleapis.com/gcm/send
      Content-Type:application/json
      Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
      
      { "data": {
          "score": "5x1",
          "time": "15:10"
        },
        "to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."
      }
      

      【讨论】:

      • 所以如果你想发送推送,你必须有“to:...”?如果我想从客户端向所有用户发送推送怎么办? (例如管理员客户端..)
      【解决方案4】:

      您可能忘记将标头中的内容类型指定为 JSON。

      Content-Type: application/json
      

      如果省略 Content-Type,则假定格式为纯文本。

      对于纯文本,注册 ID 是在一个名为 registration_id 的参数中传递的,而不是 registration_ids,这解释了您的 MissingRegistration 错误。

      【讨论】:

      • 2019年还是有道理的!
      • @SatyajitBehera 也许你有不同的问题。我已经有好几年没有使用 GCM 了,但这个答案似乎对某些人仍然有帮助(基于最近的投票)。
      猜你喜欢
      • 2013-04-04
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-07
      相关资源
      最近更新 更多