snowwolf007cn / laravel-jpusher
JPush integration to laravel framework
Requires
- jpush/jpush: ^3.5
- laravel/framework: ^5.5
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is not auto-updated.
Last update: 2025-05-19 09:53:09 UTC
README
JPush integration to laravel framework
Table of Contents
Installation
Composer
Execute the following command to get the latest version of the package:
composer require snowwolf007cn/laravel-jpusher
Laravel
>= laravel5.5
ServiceProvider will be attached automatically
Broadcaster
Config JPush Broadcaster
Add following code into your config/broadcasting.php under 'connection'
'jpush' => [ 'driver' => 'jpush', 'app_key' => env('JPUSH_APP_KEY'), 'master_secret' => env('JPUSH_MASTER_SECRET'), ],
fill your app key and secret in .env
Set Audience
Audiences are mapped to channels in laravel, and you can config channels like this.
Broadcast::channel('all', function ($user, $id) { return true; }); Broadcast::channel('tag.{tag_name}', function ($user, $id) { return true; });
examples above set two channels for diffrent audience configuration, All and Tag
Add Payload
Platforms, Notifications, Message and Options are send to broadcaster as payload in an array, which will be serialized in json and send to server.Platforms are default to 'all', i.e.
/** * Add payload to broadcast. */ public function broadcastWith() { return [ 'message' => [ 'msg_content' => 'Hi,JPush', 'content_type' => 'text', 'title' => 'msg', ], ]; }
Read more on how to broadcasting event and JPush API