webimpacto / laravel-app4less
Laravel 提供者和 App4Less APPs 数据库迁移
1.0.0
2018-05-10 11:47 UTC
Requires
- webimpacto/app4less: ^1.0
- whichbrowser/parser: ^2.0
This package is not auto-updated.
Last update: 2024-09-25 15:24:39 UTC
README
此包使您能够通过 Laravel 发送 app4less/reskyt 推送通知变得容易。
安装
您可以通过 composer 安装此包
composer require webimpacto/laravel-app4less
首先,您必须安装服务提供者(对于 Laravel >=5.5 可跳过)
// config/app.php 'providers' => [ ... \Webimpacto\LaravelApp4Less\Providers\App4LessServiceProvider::class, ],
运行 artisan migrate,以创建数据库表。
php artisan migrate
将 \Webimpacto\LaravelApp4Less\Middleware\App4lessSaveToken 中间件添加到 Http Kernel 中的 web 组,这将存储令牌在 App4less 表中。
// app/Http/Kernel.php protected $middlewareGroups = [ ... \Webimpacto\LaravelApp4Less\Middleware\App4lessSaveToken::class ],
设置 .env 变量以用于您的 App 用户和 App API KEY,如果您想发送推送通知
APP4LESS_USER=userapp APP4LESS_APIKEY=user_api_key
使用方法
现在您可以在通知中的 via() 方法内使用通道,以及发送 app4less 推送通知。
use Illuminate\Notifications\Notification; use Webimpacto\LaravelApp4Less\Channel\App4LessPushChannel; use Webimpacto\LaravelApp4Less\Channel\App4LessPushMessage; class AccountApproved extends Notification { public function via($notifiable) { return [App4LessPushChannel::class]; } public function toApp4LessPush($notifiable) { $user = User::find($this->friend->user_from); return (new App4LessPushMessage) ->title('Notification Title') ->url('Notification URL') ->utm('UTM-Analytics'); } }