在哪里可以找到 Firebase 云消息传递的 Reference_Id? [英] Where to find Reference_Ids for Firebase Cloud Messaging?

查看:14
本文介绍了在哪里可以找到 Firebase 云消息传递的 Reference_Id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过大量阅读和谷歌搜索后,我似乎已经为 Google Cloud Messaging 完成了发送推送通知的设置.我缺少的链接是我必须用来定位应用程序的 Reference_Ids.我创建了一个项目并将我的应用程序添加到其中.

After a lot of reading and Googling it seems I have made a complete setup for Google Cloud Messaging to send push-notifications. My missing link is the Reference_Ids that I must use to target apps. I have created a project and also added my apps to it.

当我向 GCM 发送推送请求时,我收到以下响应:

When I send a push-request to GCM I get the following response:

{"multicast_id":7952352701122753715,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
    StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      X-Content-Type-Options: nosniff
      X-Frame-Options: SAMEORIGIN
      X-XSS-Protection: 1; mode=block
      Alt-Svc: quic=":443"; ma=2592000; v="35,34"
      Vary: Accept-Encoding
      Transfer-Encoding: chunked
      Accept-Ranges: none
      Cache-Control: max-age=0, private
      Date: Wed, 21 Dec 2016 16:12:43 GMT
      Server: GSE
      Content-Type: application/json; charset=UTF-8
      Expires: Wed, 21 Dec 2016 16:12:43 GMT
    }

错误显示为InvalidRegistration".

所以我的问题是:

  • 在哪里可以找到我的注册 ID?
  • 作为一个相关的后续问题,我在哪里可以找到每个使用应用或特定组或用户的 Registration_Id?

顺便说一句:我找到了一个相关的问题,但似乎没有关于在哪里可以找到这些 ID 的答案.StackOverflow 帖子.

BTW: I found a related question, but it does not seem to have an answer to as where to find these Ids. StackOverflow post.

推荐答案

InvalidRegistration 表示你使用的注册令牌(registration id)无效(不存在,格式错误):

InvalidRegistration means that the registration token (registration id) you used is invalid (doesn't exist, wrong format):

检查您传递给服务器的注册令牌的格式.确保它与客户端应用通过 Firebase 通知注册收到的注册令牌相匹配.不要截断或添加其他字符.

Check the format of the registration token you pass to the server. Make sure it matches the registration token the client app receives from registering with Firebase Notifications. Do not truncate or add additional characters.

确保您使用正确且对应的注册令牌到您打算向其发送消息的设备.对于测试,我建议也使用 Firebase 控制台,以便您查看是否错误仍然从那里发生.

Make sure that you are using the correct and corresponding registration token to the device you intend to send the message to. For testing, I would suggest to make use of the Firebase Console too, so that you can see if the error still occurs from there.

对于 Android,您可以 通过调用检索注册令牌:

For Android, you can retrieve the registration token by calling:

FirebaseInstanceID.getToken()

然后您可以选择将令牌存储到您的应用服务器.

You may then choose to store the token to your App Server.

这篇关于在哪里可以找到 Firebase 云消息传递的 Reference_Id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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