Skip to content
This repository was archived by the owner on May 2, 2020. It is now read-only.

abraovic/phpush

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

abraovic/phpush

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.

About

Send push notifications to iOS and Android by PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages