1. Go to this page and download the library: Download abraovic/phpush library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
abraovic / phpush example snippets
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";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.