JPush integration to laravel framework
Execute the following command to get the latest version of the package:
composer require snowwolf007cn/laravel-jpusher
ServiceProvider will be attached automatically
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
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
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