2017 © Pedro Peláez
 

symfony-bundle push-bundle

Use to send push notifications

image

ronte-ltd/push-bundle

Use to send push notifications

  • Wednesday, September 13, 2017
  • by CawaKharkov
  • Repository
  • 2 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

RonteLtdPushBundle

Provide functions to send push notifications., (*1)

Features include:, (*2)

  • Send single notification
  • Send notifications on background
  • Send bulk notifications

Note: For now supports only APNS., (*3)

Install

Composer

composer require ronte-ltd/push-bundle

Init

AppKernel.php

new RonteLtd\PushBundle\RonteLtdPushBundle(),

config.yml

ronte_ltd_push:
    push_env: "%push_env%"
    push_sound: true // bool
    push_expiry: 12000 // message expiry, int value in seconds
    bg_worker_id: "%bg_worker_id%"
    gearman_server: "%gearman_server%"
    gearman_port: "%gearman_port%"

parameters.yml

push_env: "valid values: 'prod', 'dev'"
gearman_server: "Add gearman server here"
gearman_port: "Add gearman port here"
bg_worker_id: test //This will be a prefix for a background function in case multiple projects on a server using this command.

Certificates

Puth APNS sertificates files to 'var/apns' folder

Use

Send single notification

/**
 * @param string $deviceId - recipient device token
 * @param string $text - text message
 * @param array $payload - payload array
 */
 $payload = [
     'project' => $id,    // int|string name or id of an app, required
     'pushType' => $type, // int type, required
     'badge' => null,     // int|null, optional
     'headers' => [],     // array of headers, optional
     'extra' => [],       // additional info array, optional
 ];

 $credentials = [
     'certificate' => $fullPathToCertificate, // required
     'passPhrase' => $passPhrase,
     'certificationAuthorityFile' => $fullPathToCertificationAuthorityFile,
 ];
$container->get('push.pusher')->send($deviceId, $text, $payload, $creadentials);

Send notifications on background

Run push:worker:run command on background., (*4)

$payload = [
     'project' => $id,    // int|string name or id of an app, required
     'pushType' => $type, // int type, required
     'badge' => null,     // int|null, optional
     'headers' => [],     // array of headers, optional
     'extra' => [],       // additional info array, optional
 ];

$credentials = [
  'certificate' => $fullPathToCertificate, // required
  'passPhrase' => $passPhrase,
  'certificationAuthorityFile' => $fullPathToCertificationAuthorityFile,
];

$pusher = $container->get('push.pusher');
$pusher->addPush($deviceId, $text, $payload, , $creadentials);

Send bulk notifications

```php $payload = [ 'project' => $id, // int|string name or id of an app, required 'pushType' => $type, // int type, required 'badge' => null, // int|null, optional 'headers' => [], // array of headers, optional 'extra' => [], // additional info array, optional ]; $pusher = $container->get('push.apns'); $pusher->addMessage( $pusher->createMessage($deviceId, $text, $payload) ); // Use addMessage as much as needed, (*5)

$credentials = [ 'certificate' => $fullPathToCertificate, // required 'passPhrase' => $passPhrase, 'certificationAuthorityFile' => $fullPathToCertificationAuthorityFile, ];, (*6)

$pusher->runQueue($credentials);, (*7)

The Versions

13/09 2017

dev-master

9999999-dev

Use to send push notifications

  Sources   Download

MIT

The Requires