Android GCM

Cordova Android GCM Plugin
platforms: android
$ cordova plugin add


Cordova plugin for Google Cloud Messaging for Android.

Base on


cordova plugin add


Configure & Send Google Cloud Messaging Notifications

Creating a Google API project

To create a Google API project:

  • Open the Google APIs Console page.
  • Click Create project.
  • Take note of the value Project Number, it will be used later on as the GCM sender ID.

Enabling the GCM Service

To Enable the GCM service:

  • Click Enable an API button.
  • Turn the Google Cloud Messaging for Android toggle to ON.
  • In the Terms of Service page, accept the terms.

Obtaining an API Key

To obtain an API key:

  • Select the Credentials under the menu of APIS & AUTH.
  • Click Create new Key button.
  • Select the Server key in the prompt.
  • Click Create.
  • Take note of the API KEY value, as it will be used later on.

The implementation of server

This is a python example which can run on heorku.

import os
from flask import Flask
from flask import request
import requests
import json

app = Flask(__name__)

def index():
  return 'GCM Server'

@app.route('/send', methods=['POST'])
def send():
  id_str = request.form['id']
  msg_str = request.form['msg']
  data = {
  'registration_ids' : [id_str],
    'data' : {
    'msg' : msg_str

  headers = {
    'Content-Type' : 'application/json',
    'Authorization' : 'key=/**Your API KEY**/'

  url = ''

  r =, data=json.dumps(data), headers=headers)  
  return r.text


First copy src\\ to your project path, for example src\com.example.hello\

Then excute as follow in your js file:

plugin.gcm.start(<change it to your server address>, <change it to your prject number>, function(regId){

When the app starts, it checks if is already registered with GCM. If not, it registers the device with GCM, then send the registration id to the server.

Support Platforms

  • Android