PHP code example of issetbv / push-notification-bundle

1. Go to this page and download the library: Download issetbv/push-notification-bundle 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-bundle example snippets


$bundles[] = new IssetBV\PushNotificationBundle\IssetBVPushNotificationBundle();


$deviceToken = ''; //devicetoken
$center = $this->get('isset_bv_push_notification.center');
$message = new AppleMessageAps($deviceToken);
$message->getAps()->setAlert('Test apple');
$envelope = $center->queue($message);
$center->flushQueue();
echo $envelope->getState();


$deviceToken = ''; //devicetoken
$center = $this->get('isset_bv_push_notification.center');
$message = new AndroidMessage($deviceToken);
$message->addToPayload('notification', ['title' => 'Test android']);
$envelope = $center->queue($message);
$center->flushQueue();
echo $envelope->getState();


$center = $this->get('isset_bv_push_notification.center');
$message = new WindowsMessage('https://cloud.notify.windows.com/?token=AQE%bU%2fSjZOCvRjjpILow%3d%3d');
$message->addToPayload('wp:Text1', 'Test windows');
$envelope = $center->queue($message);
$center->flushQueue();
echo $envelope->getState();


$center = $this->get('isset_bv_push_notification.center');
$message = new WindowsMessage('https://cloud.notify.windows.com/?token=AQE%bU%2fSjZOCvRjjpILow%3d%3d');
$message->addToPayload('wp:Text1', 'Test windows');
$envelope = $center->queue($message, 'live_other');
$center->flushQueue(); 
// if you only want to flush the live_other queue
// $center->flushQueue('live_other'); 
echo $envelope->getState();