Looking to hire Laravel developers? Try LaraJobs
This package is not available.

laravel-jpusher maintained by snowwolf007cn

Description
JPush integration to laravel framework
Author
Last update
2018/05/07 13:51 (dev-master)
License
Links
Downloads
144

Comments
comments powered by Disqus

laravel-jpusher

JPush integration to laravel framework

Latest Stable Version Total Downloads Latest Unstable Version License

Table of Contents

  • Installation
    • Composer
    • Laravel
  • braodcaster
    • Config JPush Broadcaster
    • Set Audience
    • Add Payload

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