Android GCM SENDER_ID,如何获取它? [英] Android GCM SENDER_ID, how to get it?

查看:530
本文介绍了Android GCM SENDER_ID,如何获取它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试迁移到 GCM ,并且我需要提供的 SENDER_ID 存在问题。我使用谷歌的演示项目。在这个项目中,如果我明白这一点,我需要在CommonUtilities.java文件中向应用程序提供 SENDER_ID



我提供的SENDER_ID是我在 https://code.google.com/apis/console/ ,并具有以下格式: AIzaSyAxxxxxxx_xxxxxxxxxxxnoGZw (共40个字符)。



使用此字符串作为 SENDER_ID 我在BroadcastReceiver mHandleMessageReceiver上得到一条错误消息:来自GCM:错误(INVALID_SENDER)。



错误在哪里?我提供的字符串不是 SENDER_ID



谢谢。

解决方案

不,SENDER_ID是您在Google API控制台注册的项目ID,它应该是一个数字字符串。例如在您的浏览器URI上,您应该看到以下内容:

  https://code.google.com/apis/console/#project :4815162342 

发件人ID是4815162342



更新回答:

Google尚未完全更新文件。上面的答案是旧的,它基于这个文档,它似乎还没有更新。



根据更新后的 Google文档,但似乎 Google API控制台上的项目编号用作 SENDER ID


I try to migrate to GCM and I have an issue with the SENDER_ID I need to provide. I use the demo project from google. In this project I need, if I understand this well, to provide a SENDER_ID to the application in the CommonUtilities.java file.

The SENDER_ID I provided is the API key I registered on https://code.google.com/apis/console/ and has this form: AIzaSyAxxxxxxx_xxxxxxxxxxxnoGZw (total 40 chars).

Using this string as SENDER_ID I get on "BroadcastReceiver mHandleMessageReceiver" an error message: From GCM: error (INVALID_SENDER)..

Where is the mistake? The string I provide is not the SENDER_ID?

Thank you.

解决方案

No, the SENDER_ID is the project ID you signed up at Google API console, it should a numeric string. e.g. on your browser URI, you should see this:

https://code.google.com/apis/console/#project:4815162342

The Sender ID is 4815162342

Updated Answer:

Google has not updated its docs completely. The above answer is old and its based on this documentation and it seems that its still not updated.

According to updated Google docs, it seems that Project Number on Google API Console is used as SENDER ID

这篇关于Android GCM SENDER_ID,如何获取它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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