abraovic/phpush

This package is abandoned and no longer maintained. No replacement package was suggested.

Send push notifications to iOS and Android by PHP

v0.2.1 2016-04-28 08:24 UTC

This package is auto-updated.

Last update: 2020-05-22 17:07:56 UTC


README

Installation

The preferred method of installation is via Packagist and Composer. Run the following command to install the package and add it as a requirement to your project's composer.json:

composer require abraovic/phpush

Examples

You can find more examples under examples section of this lib

<?php
require 'vendor/autoload.php';

use abraovic\PHPush;
use abraovic\PHPush\Exception\PHPushException;

try {

    $type = PHPush\Push\Push::IOS;
    $credentials = [
        'device_token' => 'fake-token', // for multiple use an array 'device_token' => ['fake-token-1', 'fake-token-2', ...]
        'certificate_path' => 'fake-cert',
        'certificate_phrase' => '',
        'dev' => true
    ];

    // enable printing payload before send (for development purpose)
    PHPush\Push\Push::$printPayload = true;

    $push = new PHPush\Push\Push($type, $credentials);
    $message = new PHPush\Push\Message($type, "Hello");
    $message->setBadge(200);
    $message->setBody('body');
    $iosMsg = $message->getMessage();
    $iosMsg->setSound('default');

    if ($push->sendMessage($message)) {
        echo "sent";
    }
} catch (PHPushException $e) {
    echo 'Caught exception: ' . $e->getMessage() . "\n";
}

Contributing

Contributions are welcome! Please read CONTRIBUTING for details.

Copyright and license

The abraovic/phpush library is copyright © Ante Braovic and licensed for use under the Apache2 License.