albaraam / php-gcm
A PHP library for sending messages to devices registered through Google Cloud Messaging
Installs: 3 695
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-12-21 19:21:24 UTC
README
A PHP library for sending messages to devices registered through Google Cloud Messaging.
Installation
The preferred way to install this extension is through composer.
Either run
composer require albaraam/php-gcm "~1.0.0"
or add
"albaraam/php-gcm": "~1.0.0"
to the require
section of your composer.json.
Usage
use albaraam\gcm\GCMNotification; use albaraam\gcm\GCMMessage; use albaraam\gcm\GCMClient; $notification = new GCMNotification("Title","Body"); $notification ->setIcon("noti") ->setSound("water.mp3"); ..... $message = new GCMMessage($notification, "ids"); // "ids" parameter can contain a array/single registration token or a topic key $message ->setData(['foo'=>'bar', 'baz'=>[1,2,3]]) ->setCollapseKey("collapse-key-1"); ..... $gcm = new GCMClient("YOUR_API_KEY"); $response = $gcm->send($message); var_dump($response);