libressltd/lbpushcenter

推送通知中心


README

第1步:安装 LBPushCenter

composer require libressltd/lbpushcenter

第2步:将服务提供者添加到 config/app.php 配置文件

LIBRESSLtd\LBPushCenter\LBPushCenterServiceProvider::class,

并别名

'LBPushCenter' => LIBRESSLtd\LBPushCenter\Controllers\LBPushCenter::class,

第3步:发布供应商

php artisan vendor:publish --tag=lbpushcenter --force

第4步:在主目录中使用

// Add a new device 

Push_device::add($token, $app_name);

// Send message

$device = Push_device::findOrFail($device_id); // not device token

$device->send($title, $desc); // sync push

$device->send_in_queue($title, $desc) // must run in queue

服务

// register device badge
POST: <host>/lbpushcenter/api/device
params: token, application

// remove badge
POST: <host>/lbpushcenter/api/device/<device_id>/clear_badge

// disable / enable push
PUT: <host>/lbpushcenter/api/device/<device_id>

params: enabled = 0 / 1

运行推送的命令

	// Add in app\Console\Kernel.php
    protected $commands = [
        Commands\LBPushCommand::class
    ];

    // Then run 

    // Mode all
    php artisan lbpushcenter:push // --mode=all (allias)

    // Mode master
    php artisan lbpushcenter:push --mode=master

    // Mode worker
    php artisan lbpushcenter:push --mode=worker


    // Note
    // Run mode all for normal system (optional)
    // Run master first
    // Then run worker (run as many as you want)

迁移

删除并重新迁移设备表;

使用链接:(应由 lbsidemenu 添加)

管理应用(例如:ios-dev、ios-production、ios 等):/lbpushcenter/application

管理应用类型(ios / fcm,需要手动添加):/lbpushcenter/application_type

管理所有设备:/lbpushcenter/device

管理所有通知:/lbpushcenter/notification