2017 © Pedro Peláez
 

library push-notification-bundle

image

issetbv/push-notification-bundle

  • Wednesday, April 5, 2017
  • by IssetBV
  • Repository
  • 4 Watchers
  • 0 Stars
  • 367 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 9 % Grown

The README.md

IssetBVPushNotificationBundle

Bundle for sending push notifications to apple/android/windows, (*1)

Install:

Composer:

composer require issetbv/push-notification-bundle

AppKernel.php

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

config

To send messages add connections to the isset_bv_push_notification config, (*2)

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

parameters

Default logger is the @logger to change the logger set the isset_bv_push_notification.center.logger.service to a different logger service, (*3)

isset_bv_push_notification.center.logger.service: logger

Code samples

Example apple message

<?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();

Example android message

<?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();

Example windows message

<?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();

Example sending message over other connection then the default one

<?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();

The Versions

05/04 2017

dev-master

9999999-dev http://www.isset.nl

  Sources   Download

MIT

The Requires

 

05/04 2017

dev-develop

dev-develop http://www.isset.nl

  Sources   Download

MIT

The Requires

 

05/04 2017
04/04 2017
30/03 2017
10/03 2017
08/03 2017
08/03 2017
08/03 2017

1.0.0

1.0.0.0 http://www.isset.nl

  Sources   Download

The Requires

  • php >=7.0
  • issetbv/pushnotification ^1.0