I'm trying to set up the Batch android api in order to send push notifications. On the instructions they mentioned, it has authorization key and gcm sender Key. But I have enabled only the google cloud messaging api and an api key.
Asked
Active
Viewed 1,740 times
1 Answers
1
You can follow this Google documentation on how to set up your GCM App on Android. You need to have a connection server that take messages from the application server and send them to the device. To send a message, the application server issues a POST request.
https://gcm-http.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_KEYContent-Type
:application/json
for JSON;application/x-www-form-urlencoded
;charset=UTF-8
for plain text. IfContent-Type
is omitted, the format is assumed to be plain text.
Example:
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data" : {
...
},
}
Based from this SO question:
According to updated Google docs, it seems that Project Number on Google API Console is used as SENDER ID
Here are the steps on how to get the Sender ID
:
- Open Google api console
- Create project
- Click on Left hand side menu icon
- Click on Google cloud Platform
- You would get
SenderId
from there.
Be noted that the Sender ID is the Project Number.
You can check in this tutorial on how to find Sender ID and API Key for GCM.
Hope this helps! :)
-
The tutorial on 'how to find Sender ID and API Key for GCM' may be outdated. If you need to get them using newest Google's FCM (Firebase Cloud Messaging), check my answer to: http://stackoverflow.com/questions/38863078/where-do-i-find-my-gcm-sender-id/38987472#38987472 – rafahoro Aug 17 '16 at 03:29