2017 © Pedro Peláez
 

library laravel-push-notification

Laravel 5 Package for sending push notifications to Android and iOS devices. Same as witty's with added support for Laravel 5.2, 5.3, 5.4, 5.5

image

nhiepphong/laravel-push-notification

Laravel 5 Package for sending push notifications to Android and iOS devices. Same as witty's with added support for Laravel 5.2, 5.3, 5.4, 5.5

  • Friday, September 15, 2017
  • by nhiepphong
  • Repository
  • 1 Watchers
  • 0 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 33 % Grown

The README.md

Laravel Push Notification v1.0.1

Based on https://github.com/davibennun/laravel-push-notification forked from https://github.com/larkinwhitaker/laravel-push-notification, (*1)

Added support for Laravel 5.2 => 5.5.*., (*2)

Installation

Installing the package, (*3)

composer require nhiepphong/laravel-push-notification

Register the PushNotification service provider by adding it to the providers array in the config/app.php file., (*4)

'providers' => array(
    'Nhiepphong\LaravelPushNotification\PushNotificationServiceProvider'
)

Alias the PushNotification facade by adding it to the aliases array in the config/app.php file., (*5)

'aliases' => array(
    'PushNotification'      => 'Nhiepphong\LaravelPushNotification\PushNotification',
)

Configuration

Copy the config file into your project by running, (*6)

php artisan vendor:publish

This will generate a config file like this, (*7)

array(
    'iOS'     => [
        'environment' => env('IOS_PUSH_ENV', 'development'),
        'certificate' => env('IOS_PUSH_CERT', __DIR__ . '/ios-push-notification-certificates/development/certificate.pem'),  
        'passPhrase'  => env('IOS_PUSH_PASSWORD', '291923Job'),
        'service'     => 'apns'
    ],

    'android' => [
        'environment' => env('ANDROID_PUSH_ENV', 'development'),
        'apiKey'      => env('ANDROID_PUSH_API_KEY', 'yourAPIKey'),
        'service'     => 'gcm'
    ]
);

Where all first level keys corresponds to an service configuration, each service has its own properties, android for instance have apiKey and IOS uses certificate and passPhrase. You can set as many services configurations as you want, one for each app. A directory with the name 'ios-push-notification-certificates' will be added to the config folder for you to store both development and production certificates., (*8)

Dont forget to set service key to identify iOS 'service'=>'apns' and Android 'service'=>'gcm'

Usage


PushNotification::app('iOS') ->to($deviceToken) ->send('Hello World, i`m a push message');

Where app argument appNameIOS refers to defined service in config file. To multiple devices and optioned message:, (*9)

$devices = PushNotification::DeviceCollection(array(
    PushNotification::Device('token', array('badge' => 5)),
    PushNotification::Device('token1', array('badge' => 1)),
    PushNotification::Device('token2')
));
$message = PushNotification::Message('Message Text',array(
    'badge' => 1,
    'sound' => 'example.aiff',

    'actionLocKey' => 'Action button title!',
    'locKey' => 'localized key',
    'locArgs' => array(
        'localized args',
        'localized args',
    ),
    'launchImage' => 'image.jpg',

    'custom' => array('custom data' => array(
        'we' => 'want', 'send to app'
    ))
));

collection = PushNotification::app('appNameIOS')
    ->to($devices)
    ->send($message);

// get response for each device push
foreach ($collection->pushManager as $push) {
    $response = $push->getAdapter()->getResponse();
}

// access to adapter for advanced settings
$push = PushNotification::app('appNameAndroid');
$push->adapter->setAdapterParameters(['sslverifypeer' => false]);

This package is wrapps [Notification Package] and adds some flavor to it. ```, (*10)

Usage advice

This package should be used with Laravel Queues, so pushes dont blocks the user and are processed in the background, meaning a better flow., (*11)

The Versions

15/09 2017

dev-master

9999999-dev

Laravel 5 Package for sending push notifications to Android and iOS devices. Same as witty's with added support for Laravel 5.2, 5.3, 5.4, 5.5

  Sources   Download

MIT

The Requires

 

by Nhiep Phong

laravel laravel 5 notification ios push android

15/09 2017

1.0.1

1.0.1.0

Laravel 5 Package for sending push notifications to Android and iOS devices. Same as witty's with added support for Laravel 5.2, 5.3, 5.4, 5.5

  Sources   Download

MIT

The Requires

 

by Nhiep Phong

laravel laravel 5 notification ios push android

14/09 2017

1.0.0

1.0.0.0

Laravel 5 Package for sending push notifications to Android and iOS devices. Same as witty's with added support for Laravel 5.2, 5.3, 5.4, 5.5

  Sources   Download

MIT

The Requires

 

by Nhiep Phong

laravel laravel 5 notification ios push android