Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do we need Api Key for Google GCM implementation

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

like image 932
abi Avatar asked Jun 06 '26 04:06

abi


1 Answers

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.

(Source)

like image 163
Eran Avatar answered Jun 08 '26 19:06

Eran