yieldstudio / laravel-expo-notifier
使用 Laravel 轻松发送 Expo 通知。
0.0.15
2024-06-14 09:56 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 yieldstudio/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()) ->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()) ->to([$notifiable->expoTokens->value]) ->title('A beautiful title') ->body('This is a content') ->channelId('default') ->shouldBatch();
别忘了安排 expo:notifications:send
命令。
单元测试
要运行测试,只需运行 composer install
和 composer test
。
更新日志
有关最近更改的更多信息,请参阅 更新日志。
贡献
有关详细信息,请参阅 贡献指南。
安全性
如果您发现有关安全的错误,请通过 contact@yieldstudio.fr 邮件联系,而不是使用问题跟踪器。
鸣谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。