Login   Register  
PHP Classes

File: README.md

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Christiaan Baartse  >  PHP Google Cloud Messaging Server  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/plain
Description: Documentation
Class: PHP Google Cloud Messaging Server
Send messages to Android applications using GCM
Author: By
Last change:
Date: 1 year ago
Size: 1,217 bytes


Class file image Download
[![Build Status](https://travis-ci.org/Web-Power/GCMApplicationServer.png?branch=master)](https://travis-ci.org/Web-Power/GCMApplicationServer)

This is a port to PHP of the official [com.google.android.gcm.server JAVA package](http://developer.android.com/reference/com/google/android/gcm/server/package-summary.html).

$sender = new \WebPower\gcm\server\Sender('your google cloud messaging api key');
$message = \WebPower\gcm\server\Message::builder()
    ->addData('message', 'Hoi')
// Send to a single device using text/plain
$result = $sender->singleSendNoRetry($message, 'registration id');
// or to multiple devices using application/json
$result = $sender->sendNoRetry($message, array('registration id', 'another registration id'));
echo $result; // all value objects support __toString just like the Java code
The Api key can be generated at the [apis console](https://code.google.com/apis/console/)

Registration ids are obtained by the Android App when it registers itself on the GCM service. It should be forwarded to your PHP code.

composer.phar require webpower/gcm-application-server