Bundle for sending push notifications to apple/android/windows
composer require issetbv/push-notification-bundle
$bundles[] = new IssetBV\PushNotificationBundle\IssetBVPushNotificationBundle();
To send messages add connections to the isset_bv_push_notification config
isset_bv_push_notification:
#connection_handler: //overwrite the connection handler for all notifiers which don't have there own connection handler set
apple:
#connection_handler: connection handler for this notifier
connections:
live:
key_location: <path_to_key>
key_password_phrase: <password_phrase>
default: true
android:
connections:
live:
api_key: <api-key>
default: true
windows:
connections:
live:
default: true
live_other:
default: true
Default logger is the @logger to change the logger set the isset_bv_push_notification.center.logger.service to a different logger service
isset_bv_push_notification.center.logger.service: logger
<?php
$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();
<?php
$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();
<?php
$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();
<?php
$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();