1. Go to this page and download the library: Download issetbv/push-notification 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/ */
issetbv / push-notification example snippets
use IssetBV\PushNotification\Type\Android\AndroidConnection;
use IssetBV\PushNotification\Type\Android\Message\AndroidMessage;
$connection = new AndroidConnection(
$name, // 'android'
$api_url, // 'https://fcm.googleapis.com/fcm/send'
$api_key, // 'super-secret-api-key
);
$message = new AndroidMessage('my-device-token');
$message->addToPayload('notification', ['title' => 'Test android']);
$response = $connection->sendAndReceive($message);
echo $response->isSuccess(); // should be true
use IssetBV\PushNotification\Type\Apple\AppleConnection;
use IssetBV\PushNotification\Type\Apple\Message\AppleMessageAps;
$connection = new AppleConnection(
$name, // 'apple'
$api_url, // 'ssl://gateway.push.apple.com:2195'
$pemFile, // __DIR__ '/pemfile.pem'
$passPhrase // 'super-secret-passphrase'
);
$appleMessage = new AppleMessageAps('my-device-identifier');
// see notes below as to why we don't use ->addToPayload()
$appleMessage->getAps()->setAlert('Test apple');
$response = $connection->sendAndReceive($appleMessage);
echo $response->isSuccess(); // should be true
use IssetBV\PushNotification\Type\Windows\Message\WindowsMessage;
use IssetBV\PushNotification\Type\Windows\WindowsConnection;
$connection = new WindowsConnection('windows');
$windowsMessage = new WindowsMessage('https://cloud.notify.windows.com/?token=AQE%bU%2fSjZOCvRjjpILow%3d%3d');
$windowsMessage->addToPayload('wp:Text1', 'Test Windows');
$response = $connection->sendAndReceive($windowsMessage);
echo $response->isSuccess(); // should be true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.