Reputation: 1002
Do we need the API Key that we get from Google Cloud Console for implementation of GCM?
If yes, where do we use it?
In my understanding, we get registration id when calling the method
gcm.register(SENDER_ID)
where
SENDER_ID
is a project number you acquire from the API console.
Guide me
Thanks in advance
Upvotes: 3
Views: 370
Reputation: 393771
You use the API key in your server when you send GCM messages to your devices.
When you send a HTTP request to GCM HTTP connection server, your headers must include Authorization: key=YOUR_API_KEY
or the request will fail.
To send a message, the application server issues a POST request to https://android.googleapis.com/gcm/send.
A message request is made of 2 parts: HTTP header and HTTP body.
The HTTP header must contain the following headers:
Authorization: key=YOUR_API_KEY
Content-Type: application/json for JSON; application/x-www-form-urlencoded;charset=UTF-8 for plain text.
Upvotes: 2