雪狼007cn / laravel-jpusher
JPush集成到laravel框架中
dev-master
2018-05-07 11:51 UTC
Requires
- jpush/jpush: ^3.5
- laravel/framework: ^5.5
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is not auto-updated.
Last update: 2024-09-23 06:53:44 UTC
README
JPush集成到laravel框架中
目录
安装
Composer
执行以下命令以获取软件包的最新版本
composer require snowwolf007cn/laravel-jpusher
Laravel
>= laravel5.5
ServiceProvider将被自动附加
广播器
配置JPush广播器
将以下代码添加到您的config/broadcasting.php文件下的'connection'
'jpush' => [ 'driver' => 'jpush', 'app_key' => env('JPUSH_APP_KEY'), 'master_secret' => env('JPUSH_MASTER_SECRET'), ],
在.env文件中填写您的app key和secret
设置受众
受众在laravel中被映射到频道,您可以这样配置频道。
Broadcast::channel('all', function ($user, $id) { return true; }); Broadcast::channel('tag.{tag_name}', function ($user, $id) { return true; });
上述示例为不同的受众配置设置了两个频道,分别是所有和标签
添加有效载荷
平台、通知、消息和选项作为数组的有效载荷发送到广播器,将序列化为json并发送到服务器。平台默认为'所有',即。
/** * Add payload to broadcast. */ public function broadcastWith() { return [ 'message' => [ 'msg_content' => 'Hi,JPush', 'content_type' => 'text', 'title' => 'msg', ], ]; }