Download the PHP package bnbwebexpertise/laravel-push-notifications without Composer
On this page you can find all versions of the php package bnbwebexpertise/laravel-push-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bnbwebexpertise/laravel-push-notifications
More information about bnbwebexpertise/laravel-push-notifications
Files in bnbwebexpertise/laravel-push-notifications
Package laravel-push-notifications
Short Description Apple and Google Push Notification
License MIT
Informations about the package laravel-push-notifications
[DEPRECATED] Apple and Google Push Notifications for Laravel 5
Use Firebase Cloud Messaging
Installation
For Laravel 5.4 or older, add the provider in your config/app.php
:
Laravel 5.5 use Composer auto-discovery feature.
Configuration
Configuration via environment
To return the APNs payloads in the results array (debugging purpose) :
PUSH_RETURN_PAYLOADS=true
Apple Push Notification Service
Put your APNs certificate somewhere inside your project path. Add the relative path to your certificate in your .env
file :
PUSH_APNS_CERTIFICATE=config/push/certificate.pem
If your certificate is secured with a password you can specify it in the .env
file as :
PUSH_APNS_PASSWORD=changeme
You can also set the environnement to use (default to production
) :
PUSH_APNS_ENVIRONMENT=development
Google Cloud Messaging
Grap you API key from the Google Developer Console and add it to your .env
file :
PUSH_GCM_KEY=AIaeRtYiUoP-QsDfghQJK1lMWXCvBN23AZE4RT6u
Configuration via PHP
If you prefer to configure the module from a config
PHP file, publish it :
php artisan vendor:publish --provider=Bnb\\PushNotifications\\PushNotificationsServiceProvider --tag=config
Then set the desired configuration values :
Configuration at runtime
The GCM and APNs configuration can be changed at runtime via the setGcmOption($key, $value)
and setApnsOption($key, $value)
methods of the Notification
class.
GCM options
Key | Default | Description |
---|---|---|
key | config('push.gcm.key') |
The GCM server API key |
APNs options
Key | Default | Description |
---|---|---|
certificate | base_path(config('push.apns.certificate')) |
The APNs certificate path on the server filesystem |
password | config('push.apns.password') |
The APNs certificate password |
environment | config('push.apns.environment') |
The APNs environnement |
Usage
A notification message holds the following properties where each one can be overridden by the device definition :
Name | Type | Description |
---|---|---|
title | string | The title displayed in the notification bar |
message | message | The message displayed in the notification bar (platform dependent) |
badge | int | The badge number displayed in the notification bar |
sound | string | The sound to play when the notification is received (platform dependent) |
ttl | int | Number of seconds after which the message is expired by the network |
metadata | array | Key/Value pairs of custom data |
Metadata
For APNs the props
custom property holds the list of the metadata keys including title
and message
.
For GCM the metadata
are bound to the appdata
object.
Example
Commands
You can use the following Artisan command lines to send test messages :
Send to Android devices
php artisan push:gcm [options] [--] <token> <message> [<title>]
Example :
Send to iOS devices
php artisan push:apns [options] [--] <token> <message> [<title>]
Example :