Google Cloud Messaging: How to use SHA1 certificate?

流过昼夜 提交于 2019-12-12 10:06:56

问题


I have a doubt. I developed an Android App which receives push notifications via Google Cloud Messaging.

Here are the steps I took:

  1. Creation of new Project on Google Developer console and copy/paste my Project Number in my android app.
  2. Registration of my App through RegID previously received by Google Cloud Messaging. Result: Ok! My App appears in database on my server.
  3. Copying/paste Api Key in my Server. I obtained my Api Key from Google Developer Console (Projcet/API/Credential/New API Key) creating new API Key without putting any SHA1 certificate.

I exported my application (I use Android Development Tool SDK), created a keystore and apk file. I noticed that when I create a new keystore I receive also a SHA1 certificate (an alpha numeric string like this: 54:B9:D6:B4:....)

Do I have to use this SHA1 code to generate a new API Key from Google Developer Console and use this new Api Key in my Server to send push notifications to my Android App?

In this moment I'm using the API Key generated in step 3 above. Help me to clarify my doubt.


回答1:


Well, here are the steps states in the GCM documentation:

  1. In the sidebar on the left, select APIs & auth > Credentials.
  2. Under Public API access, click Create new key.
  3. In the Create a new key dialog, click Android key.
  4. In the resulting configuration dialog, supply one SHA1 fingerprint and the package name for your app, separated by a semicolon. For example, 45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:12:17:F2:56:26:A0:E0;com.myexample.

To get the value for the SHA1 fingerprint, follow the instructions in the console help. 5. Click Create.

In step 4, you can enter the SHA1 fingerprint and package name in this dialog:

It doesn't seem mandatory, though. If you click Create without entering anything, the API Key is created, and it says Android applications: Any application allowed. I guess you can enter the SHA1 in order to limit usage of that API Key to a specific application. You can add the SHA1 for an existing API Key by clicking Edit allowed Android applications.



来源:https://stackoverflow.com/questions/21377251/google-cloud-messaging-how-to-use-sha1-certificate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!