Skip to content

An example program that will use Google Cloud Messaging to send a notifications.

License

Notifications You must be signed in to change notification settings

mozi22/GCM-Notification-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GCM-Notification-Example

This is a complete android+PHP program that will help you understand how can you use Google Cloud Messaging to send notifications to a device.

What this Program will do

This program will register the android device to get a device registrationID from GCM servers and then send it to the PHP script(GCMPushMessage.php) which in turn will send a notification back to this device using the sent registrationID.

How to use

  • Follow this tutorial and get the ProjectID and API KEY.
  • Now open the android project and open MainActivity and replace the SENDER_ID there with your ProjectID.
  • Then open GCMPushMessage.php and replace the SERVER_key with your API KEY.
  • Goto Android strings.xml and replace the server_address with the general path of your server. (For e.g http://localhost).

How Does it work

When you will run the program the following operations occur. > ## Operations > Android (gcmTester) PHP(GCMPushMessage.php) GCM Servers > | | Get Device RegistrationID | > |--------------------------------|------------------------------------------->| > | Send RegistrationID to server | | > |------------------------------->| | > | | Send Notification to this registrationID | > | |------------------------------------------->| > | | Send Notification To Device with RegID | > |<-------------------------------|--------------------------------------------| > | | |

Note : The author of GCMPushMessage.php is Matt Grundy. I've slightly modified it to handle trouble situations also as mentioned in the developer docs.

License

Copyright 2013 Muazzam Ali

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

An example program that will use Google Cloud Messaging to send a notifications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published