API Reference for GCM service

This document explains sending messages to chrome.pushMessaging API, which is deprecated since Chrome 38. The API will be removed in Chrome 41. Use the new Google Cloud Messaging.

The Google Cloud Messaging for Chrome service sends messages to users of a Chrome App. The service handles all aspects of queueing and delivering messages. To use the service, you must agree to the Google Cloud Messaging for Chrome API Terms of Service.

Messages must conform to these constraints:

  • Maximum payload length: 256 bytes
  • Maximum subchannels: 4
  • Maximum API requests per day: 10,000

Google API client libraries

You may use the REST interface defined here to access Google Cloud Messaging for Chrome from your application. We also offer Google API client libraries for a number of popular programming languages that can be used to access the API. For more information, see Google APIs Client Libraries.

Insert method

The gcm_for_chrome.messages.insert method sends a message to your app or extension user.

Authentication

Authentication is required to send messages to users. Using OAuth 2.0 for Web Server Applications describes this in greater detail.

URL

The URL used to obtain access to the GCM for Chrome service: https://accounts.google.com/o/auth2/auth.

Required parameters

The required set of query string parameters are:

Parameter Description
client_id Indicates the app or extension client that is making the request. Obtained from the Google APIs Console; the parameter value must exactly match the client ID shown in the console.
client_secret The client secret obtained during registration in Google APIs Console.
refresh_token Token associated with app or extension used to obtain new access token.
grant_type The authorization_code value of refresh_token.

Response

The authorization response includes:

Field Description
access_token Valid token required to access the GCM for Chrome service.
expires_in Time until access token expires in seconds.
token_type The returned token type, Bearer.

Message request

HTTP request

POST https://www.googleapis.com/gcm_for_chrome/v1/messages

Request body

In the request body, supply:

Parameter Description
Content-Type The request body content type, application/json.
Authorization Bearer HTTP header including access token, for example, Bearer 1/fFBGRNJru1FQd44AzqT3Zg.
channelId The app or extension channel ID required to push messages back to the app or extension.
subchannelId The subchannel to send the message on; only values 0-3 are valid.
payload The message body (up to 256 bytes). This should not include any personally identifiable information.

Back to top