dev-master
9999999-devPHP Package to send push notifications
MIT License
Wallogit.com
2017 © Pedro Peláez
PHP Package to send push notifications
PHPush is a PHP package that provide a simple API to send push notifications to foreign platforms., (*2)
Currently, we support 3 platforms - Android, iOS, and Google Chrome., (*3)
Add the package in your composer.json by executing the following command:, (*4)
composer require mhamlet/phpush
The following examples demonstrate how to send Push notifications with text "Hello, World!" to 2 devices in different platforms., (*5)
```php // Include composer autoloader require_once 'vendor/autoload.php';, (*6)
use PHPush\PHPush;, (*7)
// Setting environment PHPush::Environment(PHPush::ENVIRONMENT_PRODUCTION);, (*8)
// Adding Android key PHPush::Provider(\PHPush\Provider::PROVIDER_ANDROID)->setAccessKey('test');, (*9)
// Adding iOS certificate PHPush::Provider(\PHPush\Provider::PROVIDER_IOS)->setCertificate('ck.pem');, (*10)
// Creating new queue $queue = PHPush::Queue();, (*11)
// Adding some devices $queue->add(new \PHPush\providers\android\Device('android_registration_id')); $queue->add(new \PHPush\providers\chrome\Device('chrome_registration_id')); $queue->add(new \PHPush\providers\ios\Device('ios_device_token'));, (*12)
// Setting message $queue->message('Hello World!');, (*13)
// Send message. You can provide custom fields to this method. // Also you can pass sound and passphrase with this custom fields $queue->send(array( 'custom' => 'field', 'sound' => 'popup.aif', 'passphase' => 'phpush', ));, (*14)
// Creating another queue $another_queue = PHPush::Queue();, (*15)
// Adding only one device $another_queue->add(new \PHPush\providers\ios\Device('another_or_the_same_ios_device_token'));, (*16)
// Setting message $another_queue->message('Hello World! I\'m second queue!');, (*17)
// This will not open a connection to APNS server again. // It will use the old connection $another_queue->send();, (*18)
PHP Package to send push notifications
MIT License