Skip to content
/ GCM Public

A PHP library to send messages to devices registered through Google Cloud Messaging

License

Notifications You must be signed in to change notification settings

bigbank-as/GCM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Cloud Messaging (GCM)

A PHP library to send messages to devices registered through Google Cloud Messaging

See GCM documentation: http://developer.android.com/guide/google/gcm/index.html

Example usage

use Bigbank\Gcm\Sender;
use Bigbank\Gcm\Message;

$sender = new Sender("YOUR GOOGLE API KEY", $GcmEndpoint);

$message = new Message(
        ["device_registration_id1", "device_registration_id2"],
        ["data1" => "123", "data2" => "string"]
);

$message
    ->notification(["title" => "foo", "body" => "bar"])
    ->setCollapseKey("collapse_key")
    ->setDelayWhileIdle(true)
    ->setTtl(123)
    ->setRestrictedPackageName("com.example")
    ->setDryRun(true)
;

try {
    $response = $sender->send($message);
} catch (\Exception $exception) {
    throw new \Exception($exception->getMessage());
}

Note about cURL SSL verify peer option

Library has turned off CURLOPT_SSL_VERIFYPEER by default, but you can enable it by passing third parameter into constructor of Sender class.

You need to download root certificates and add them somewhere into your project directory. Then construct Sender object like this:

use Bigbank\Gcm\Sender;

$sender = new Sender("YOUR GOOGLE API KEY", $GcmEndpoint, "/path/to/cacert.crt");

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Credits

  • [Bigbank's developers][link-bb-developers]
  • [All Contributors][link-contributors]

License

The Apache 2 License. Please see License File for more information.

About

A PHP library to send messages to devices registered through Google Cloud Messaging

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages