iskander-g/laravel-huawei-push
Composer 安装命令:
composer require iskander-g/laravel-huawei-push
包简介
Huawei Push For Laravel Notifications
README 文档
README
Installing
# composer.json
"minimum-stability": "dev",
"prefer-stable": true,
$ composer require "davidlowcj/laravel-huawei-push" -vvv
Config
# optional if >= 5.5 # config/app.php <?php return [ 'providers' => [ Davidlowcj\LaravelHuaweiPush\ServiceProvider::class, ], ];
# config/services.php [ 'huawei_push' => [ 'appid' => '1234567890123456', 'secret' => 'abcdefghijklmn==', 'bundles' => [ // 多包名 'com.app.bundle_id' => [ 'appid' => '1234567890123456', 'secret' => 'abcdefghijklmn==', ], ], ], ];
Usage
<?php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; class User extends Model { use Notifiable; /** * 推送路由 */ public function routeNotificationForHuaweiPush() { return $this->huawei_push_token; } /** * 如果不同用户所属的APP包名可能不同,请添加此方法 */ public function getAppPackage() { return 'com.app.bundle_id'; } }
<?php use Illuminate\Support\Facades\Notification; use Davidlowcj\LaravelHuaweiPush\HuaweiNotification; use Davidlowcj\LaravelHuaweiPush\HuaweiMessage; $msg = (new HuaweiNotification) ->title('通知标题') ->body('通知内容') ->setHandler(function($msg,$notifiable,$cfg,$type = null) { if($msg instanceof HuaweiMessage) { $msg->ttl(86400); $msg->channel_id(8888); } return $msg; }); $user->notify($msg); Notification::send($users,$msg);
License
MIT
统计信息
- 总下载量: 301
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-05