fawzanm/ laravel-pushy-notification
Laravel Pushy 通知通道
1.1
2020-05-19 08:40 UTC
Requires
- php: >=7.2
- guzzlehttp/guzzle: ^6.2
- illuminate/config: ~5.5|^6.0 || ~7.0
- illuminate/notifications: ~5.5 || ~6.0 || ~7.0
- illuminate/queue: ~5.5|^6.0 || ~7.0
- illuminate/support: ~5.5 || ~6.0 || ~7.0
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-09-29 05:35:53 UTC
README
此包使用 Pushy 在 Laravel 5.5+、6.0 和 7.0 中轻松发送通知
通过从您的 Laravel 应用程序调用 Pushy REST API 来向设备发送推送通知。
内容
安装
composer require fawzanm/laravel-pushy-notification
手动注册服务提供者?
// config/app.php
'providers' => [
...
\Fawzanm\Pushy\PushyServiceProvider::class,
...
];
- 通过创建应用程序从 Pushy 获取 PUSHY_API_KEY
- 在
config/services.php
中添加一个条目,并在.env
文件中添加一个条目,格式为PUSHY_API_KEY=your_api_key
。如果您不使用环境文件,则可以用您的密钥替换default-api-key
。
'pushy' => [ 'key' => env('PUSHY_API_KEY','default-api-key') ]
设置 Pushy 服务
Pushy 提供了非常好的文档,请务必查看。
示例用法
使用 Artisan 创建通知
php artisan make:notification SomeNotification
在通知的 public function via($notifiable)
方法中返回 [pushy]
public function via($notifiable) { return ['pushy']; }
在通知中添加方法 public function toPushy($notifiable)
,并返回 PushyMessage
实例
use Fawzanm\Pushy\PushyMessage; ... public function toPushy($notifiable) { $message = new PushyMessage(); $message->notification([ 'body' => 'Hello, World..', 'badge' => 1, 'sound' => 'ping.aiff' ])->data([ 'type' => 'notification', ]); return $message; }
在向特定设备发送时,请确保您的通知实体已定义 routeNotificationForPushy
方法
/** * Route notifications for the Pushy channel. * * @param \Illuminate\Notifications\Notification $notification * @return string */ public function routeNotificationForPushy($notification) { return $this->device_token; }
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
测试
$ composer test
安全
如果您发现任何安全问题,请通过电子邮件 fawzanm@gmail.com 而不是使用问题跟踪器。
贡献
有关详细信息,请参阅 CONTRIBUTING
致谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件