Laravel 5 Package for sending push notifications to Android and iOS devices
byrontudhope/pushnotificationlaravel is a Laravel package for laravel 5 package for sending push notifications to android and ios devices.
It currently has 1 GitHub stars and 1.065 downloads on Packagist (latest version v1.1.3).
Install it with composer require byrontudhope/pushnotificationlaravel.
Discover more Laravel packages by byrontudhope
or browse all Laravel packages to compare alternatives.
Last updated
Based off of https://github.com/davibennun/laravel-push-notification with support for Laravel 5 and 5.1.
Update your composer.json file to include this package as a dependency
"byrontudhope/pushnotificationlaravel": "dev-master"
Register the PushNotification service provider by adding it to the providers array in the config/app.php file.
'providers' => array(
'ByronTudhope\LaravelPushNotification\PushNotificationServiceProvider'
)
Alias the PushNotification facade by adding it to the aliases array in the config/app.php file.
'aliases' => array(
'PushNotification' => 'ByronTudhope\LaravelPushNotification\PushNotification',
)
Copy the config file into your project by running
php artisan vendor:publish
This will generate a config file like this
array(
'iOS' => [
'environment' => env('IOS_PUSH_ENV', 'development'),
'certificate' => env('IOS_PUSH_CERT', __DIR__ . '/ios-push-notification-certificates/development/'),
'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.
service key to identify iOS 'service'=>'apns' and Android 'service'=>'gcm'
PushNotification::app('iOS')
->to($deviceToken)
->send('Hello World, i`m a push message');