gohiljayvirsinh / laravel-jwt-exponent-push-notifications
用于Laravel的Exponent推送通知驱动程序
v1.7.0
2019-04-23 09:07 UTC
Requires
- php: >=7.0
- alymosul/exponent-server-sdk-php: 1.1.*
- illuminate/auth: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
- illuminate/config: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
- illuminate/events: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
- illuminate/http: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
- illuminate/notifications: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
- illuminate/queue: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
- illuminate/routing: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
- illuminate/support: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
- illuminate/validation: 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*
Requires (Dev)
- mockery/mockery: ^0.9.5
- orchestra/testbench: ~3.3||~3.4||~3.5||~3.6||~3.7
- phpunit/phpunit: ~5.4||~5.7||~6.0||^7.0
README
内容
安装
您可以通过composer安装此包
composer require gohiljayvirsinh/laravel-exponent-push-notifications
如果您使用的是Laravel 5.5或更高版本,此包将自动使用包发现注册自身。对于Laravel的旧版本,您必须手动安装服务提供者
// config/app.php 'providers' => [ ... NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider::class, ],
在发布Exponent通知迁移之前,您必须在.env文件中添加
EXPONENT_PUSH_NOTIFICATION_INTERESTS_STORAGE_DRIVER=database
您可以使用以下命令发布迁移
php artisan vendor:publish --provider="NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider" --tag="migrations"
发布迁移后,您可以通过运行迁移来创建exponent_push_notification_interests表
php artisan migrate
您可以选择使用以下命令发布配置文件
php artisan vendor:publish --provider="NotificationChannels\ExpoPushNotifications\ExpoPushNotificationsServiceProvider" --tag="config"
这是已发布配置文件的内容
return [ 'interests' => [ /* * Supported: "file", "database" */ 'driver' => env('EXPONENT_PUSH_NOTIFICATION_INTERESTS_STORAGE_DRIVER', 'file'), 'database' => [ 'table_name' => 'exponent_push_notification_interests', ], ] ];
使用
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!"); } }
可用的消息方法
所有可用选项的列表
body(''):接受字符串值作为正文。enableSound():启用通知声音。disableSound():静音通知声音。badge(1):接受整数值作为徽章。ttl(60):接受整数值作为生存时间。
管理接收者
此包注册了两个端点,用于处理接收者的订阅,这些端点在src/Http/routes.php文件中定义,由ExpoController使用,并通过包服务提供者加载。
路由消息
默认情况下,Exponent "interest"消息将被发送到使用{notifiable}.{id}约定定义的地址,例如App.User.1,但是您可以通过在可通知类的方法中包含routeNotificationForExpoPushNotifications()来更改此行为,该方法返回兴趣名称。
变更日志
有关最近更改的更多信息,请参阅变更日志。
测试
$ composer test
安全性
如果您发现任何与安全相关的问题,请通过alymosul@gmail.com发送电子邮件,而不是使用问题跟踪器。
贡献
有关详细信息,请参阅贡献。
鸣谢
许可
MIT许可证(MIT)。有关更多信息,请参阅许可文件。