snowwolf007cn / laravel-jpusher

JPush integration to laravel framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

laravel-jpusher

JPush integration to laravel framework

Latest Stable Version Total Downloads Latest Unstable Version License

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

About

JPush integration to laravel framework


Languages

Language:PHP 100.0%