nero / laravel-expo-notifier
使用 Laravel 轻松发送 Expo 通知。
0.0.20
2024-07-20 16:14 UTC
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
使用 Laravel 轻松管理 Expo 通知。支持批量通知。
主要版本零(0.y.z)用于初始开发。任何内容在任何时候都可能发生变化。公共 API 不应被视为稳定。
安装
composer require nero/laravel-expo-notifier
配置
您必须使用以下命令发布配置文件
php artisan vendor:publish --provider="YieldStudio\LaravelExpoNotifier\ExpoNotificationsServiceProvider" --tag="expo-notifications-config" --tag="expo-notifications-migration"
可用的环境变量
EXPO_PUSH_NOTIFICATIONS_PER_REQUEST_LIMIT
: 设置批量请求中发送的最大通知数量。 官方文档表示限制应为 100 但实际上失败了。您可以通过设置小于 100 的值来调整。
使用
发送通知
<?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()) ->expoTokenId($notifiable->expoTokens->id) ->to([$notifiable->expoTokens->value]) ->title('A beautiful title') ->body('This is a content') ->channelId('default'); } }
命令使用
发送数据库挂起的通知
php artisan expo:notifications:send
从过时的令牌中清理票据
php artisan expo:tickets:check
您可以为这些命令创建计划。
批量支持
您可以在下一个批次中发送通知
(new ExpoMessage()) ->expoTokenId($notifiable->expoTokens->id) ->to([$notifiable->expoTokens->value]) ->title('A beautiful title') ->body('This is a content') ->channelId('default') ->shouldBatch();
别忘了安排 expo:notifications:send
命令。
单元测试
要运行测试,只需运行 composer install
和 composer test
。
变更日志
请参阅 CHANGELOG 了解最近更改的更多信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现有关安全的错误,请通过邮件发送 contact@yieldstudio.fr 而不是使用问题跟踪器。
致谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。