You can install the package via composer:
composer require alymosul/laravel-exponent-push-notifications
If you use Laravel <= 5.4, please use release v1.0:
composer require alymosul/laravel-exponent-push-notifications dev-master#v1.0
You must install the service provider:
// config/app.php
'providers' => [
...
NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider::class,
],
use NotificationChannels\ExpoPushNotifications\ExpoChannel;
use NotificationChannels\ExpoPushNotifications\ExpoMessage;
use Illuminate\Notifications\Notification;
class AccountApproved extends Notification
{
public function via($notifiable)
{
return [ExpoChannel::class];
}
public function toExpoPush($notifiable)
{
return ExpoMessage::create()
->badge(1)
->enableSound()
->body("Your {$notifiable->service} account was approved!");
}
}
A list of all available options
body('')
: Accepts a string value for the body.enableSound()
: Enables the notification sound.disableSound()
: Mutes the notification sound.badge(1)
: Accepts an integer value for the badge.ttl(60)
: Accepts an integer value for the time to live.
This package registers two endpoints that handle the subscription of recipients, the endpoints are defined in src/Http/routes.php file, used by ExpoController and all loaded through the package service provider.
By default the exponent "interest" messages will be sent to will be defined using the {notifiable}.{id} convention, for example App.User.1
, however you can change this behaviour by including a routeNotificationForExpoPushNotifications()
in the notifiable class method that returns the interest name.
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email alymosul@gmail.com instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.