Android GCM - 新的 Google API 控制台

标签 android push-notification google-cloud-messaging

我使用 GCM 很长时间,但使用新的 Google 控制台界面时,行为略有不同。

您必须创建项目并获取项目 ID。这是 GCM 发件人 ID。没关系。

但之后您必须创建应用程序。

GCM 文档说要创建一个应用程序并单击“Android > 直接从 Android 访问 API”。

此处的文档:http://developer.android.com/google/gcm/gs.html .

这应该是在服务器中发送消息的 API KEY,但它不起作用。

但如果我创建一个 Web 应用程序并获得“> 服务器 key > API key ”,它就可以工作了!

这有道理吗?谢谢

最佳答案

我完全按照 Android 指定的步骤进行操作,它完全按照他们所说的那样工作。

To obtain an API key:

1. In the sidebar on the left, select APIs & auth > Registered apps.
2. Click Register app.
3. In the Name field, type your app's name.
4. Click Android > Accessing APIs directly from Android.
5. Under Android identification, type the package name for your app.
6. Enter an SHA1 fingerprint. To get this value, follow the instructions in the
   console help.
7. Click Register.
8 .In the new page, open the Android Key section and copy the API key. You will need
   the API key later on to perform authentication in your application server.

然后我通过以下命令获得了 SHA1 指纹:

keytool -exportcert -alias androiddebugkey -keystore C:\Users\myusername\.android\debug.keystore -list -v

(和密码android)

关于Android GCM - 新的 Google API 控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20566079/

相关文章:

android - AWS 签名不匹配

java - Android:无法读取xml

java - 如何解决OneSignal错误: "Segment is not a valid filter field"

android - Urban Airship Android推送获取 "This app is not configured for iOS push"

java - 如何重置设备的 Google Cloud Messaging 注册?

java - 优化在android上运行youtube视频的方式

android - 将对象从 Activity 传递到 Fragments 是通过引用传递

android - 当手机离线时,GCM 存储消息列表或仅存储最后一条消息,就像 APNS 一样?

ios - iPhone 7 上未收到 GCM 推送

android - Google Cloud Messaging - onRegistered 未在 Android 9.0 Pie 上调用