Google Cloud Messaging / PUSH Notification in Android using PHP, MYSQL

It's only fair to share...Share on Facebook0Share on Google+0Tweet about this on Twitter0Share on LinkedIn0Pin on Pinterest0Digg thisShare on StumbleUpon0

Google Cloud Messaging for Android (GCM) is a free service that helps us to send data from your server to their Andriod application on Andriod devices.


GCM Architecture contains three main component.

  1. 3rd-Party Application Server: This is the server from where we host our PHP application, and sends the message to GCM Connection Severs.
  2. GCM Connection Servers: It takes message from  3rd-Party Application Server and send these messages to a GCM enabled Android application.
  3. Client App: Its a GCM enabled andriod application for a device, receives the messages from GCM connection server.

GCM Architecture

GCM Architecture – source: official GCM documentation

Registering with Google Cloud Messaging

  •  Goto Google APIs Console page and create project for API.
  •  After project creation, click “APIs and auth” from left menu.
  •  In the displayed list of APIs, turn the Google Cloud Messaging for Android toggle to ON.
  •  Once done, click on API Access and note down the API Key. This API key will be used durin GCM integration using PHP.

PHP Script for GCM / Push Notification

Sample File (sample.php)

 Gcm.php GCM Class File:


Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">