yieldstudio / laravel-expo-notifier
Easily send Expo notifications with Laravel.
Installs: 45 443
Dependents: 0
Suggesters: 0
Security: 0
Stars: 43
Watchers: 4
Forks: 11
Open Issues: 10
Type:plugin
Requires
- php: ^8.1
- illuminate/database: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- nesbot/carbon: >=2.62.1
Requires (Dev)
- ciareis/bypass: ^1.0
- dg/bypass-finals: ^1.4
- guzzlehttp/guzzle: ^7.8
- laravel/pint: ^1.3
- orchestra/testbench: ^7.0|^8.0|^9.0.2
- pestphp/pest: ^1.21|^2.0
- phpunit/phpunit: ^9.4 || ^10.5 || ^11.0
README
Easily manage Expo notifications with Laravel. Support batched notifications.
Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.
Installation
composer require yieldstudio/laravel-expo-notifier
Configure
You must publish the configuration file with:
php artisan vendor:publish --provider="YieldStudio\LaravelExpoNotifier\ExpoNotificationsServiceProvider" --tag="expo-notifications-config" --tag="expo-notifications-migration"
Available environment variables
EXPO_PUSH_NOTIFICATIONS_PER_REQUEST_LIMIT
: sets the max notifications sent on a bulk request. The official documentation says the limit should be 100 but in fact it's failing. You can tweak it by setting a value under 100.
Usage
Send notification
<?php namespace App\Notifications; use Illuminate\Notifications\Notification; use YieldStudio\LaravelExpoNotifier\ExpoNotificationsChannel; use YieldStudio\LaravelExpoNotifier\Dto\ExpoMessage; class NewSampleNotification extends Notification { public function via($notifiable): array { return [ExpoNotificationsChannel::class]; } public function toExpoNotification($notifiable): ExpoMessage { return (new ExpoMessage()) ->to([$notifiable->expoTokens->value]) ->title('A beautiful title') ->body('This is a content') ->channelId('default'); } }
Commands usage
Send database pending notifications
php artisan expo:notifications:send
Clean tickets from outdated tokens
php artisan expo:tickets:check
You may create schedules to execute these commands.
Batch support
You can send notification in the next batch :
(new ExpoMessage()) ->to([$notifiable->expoTokens->value]) ->title('A beautiful title') ->body('This is a content') ->channelId('default') ->shouldBatch();
Don't forget to schedule the expo:notifications:send
command.
Unit tests
To run the tests, just run composer install
and composer test
.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you've found a bug regarding security please mail contact@yieldstudio.fr instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.