AFS
AFS

Reputation: 1443

Authorization Key and GCM Sender ID on Batch API

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.

Upvotes: 0

Views: 1779

Answers (1)

abielita
abielita

Reputation: 13469

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_KEY
  • Content-Type: application/json for JSON; application/x-www-form-urlencoded;charset=UTF-8 for plain text. If Content-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:

  1. Open Google api console
  2. Create project
  3. Click on Left hand side menu icon
  4. Click on Google cloud Platform
  5. 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! :)

Upvotes: 1

Related Questions