问题
I have a doubt. I developed an Android App which receives push notifications via Google Cloud Messaging.
Here are the steps I took:
- Creation of new Project on Google Developer console and copy/paste my Project Number in my android app.
- Registration of my App through RegID previously received by Google Cloud Messaging. Result: Ok! My App appears in database on my server.
- 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:
- In the sidebar on the left, select APIs & auth > Credentials.
- Under Public API access, click Create new key.
- In the Create a new key dialog, click Android key.
- 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