PHP code example of sunaoka / push-notifications-php
1. Go to this page and download the library: Download sunaoka/push-notifications-php 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/ */
sunaoka / push-notifications-php example snippets
use Sunaoka\PushNotifications\Drivers\APNs;
use Sunaoka\PushNotifications\Pusher;
$payload = [
'aps' => [
'alert' => [
'title' => 'Game Request',
'body' => 'Bob wants to play poker',
],
],
];
$options = new APNs\Token\Option();
$options->payload = $payload;
$options->authKey = '/path/to/key.p8';
$options->keyId = 'ABCDE12345';
$options->teamId = 'ABCDE12345';
$options->topic = 'com.example.app';
$driver = new APNs\Token($options);
$pusher = new Pusher();
$feedback = $pusher->to('Device token')->send($driver);
$result = $feedback->isSuccess('Device token');
if (! $result) {
echo $feedback->failure('Device token');
// BadDeviceToken
}