2017 © Pedro Peláez
 

library mipush

The Hht mipush package.

image

haiaouang/mipush

The Hht mipush package.

  • Monday, August 21, 2017
  • by haiaouang
  • Repository
  • 1 Watchers
  • 0 Stars
  • 60 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 18 % Grown

The README.md

mipush

Latest Stable Version License, (*1)

laravel小米推送包, (*2)

安装

在你的终端运行以下命令, (*3)

composer require haiaouang/mipush, (*4)

或者在composer.json中添加, (*5)

"haiaouang/mipush": "1.0.*", (*6)

然后在你的终端运行以下命令, (*7)

composer update, (*8)

安装依赖包 haiaouang/support, (*9)

安装依赖包 haiaouang/pusher, (*10)

在配置文件中添加 config/app.php, (*11)

    'providers' => [
        /**
         * 添加供应商
         */
        Hht\Pusher\PusherServiceProvider::class,
        /**
         * 添加供应商
         */
        Hht\Support\ServiceProvider::class,
    ],

生成配置文件, (*12)

php artisan vendor:publish, (*13)

设置推送信息的参数 config/pushers.php, (*14)

调用

修改config/pushers.php对应的配置, (*15)

<?php

return [
    'default' => 'mipush',
    'launchers' => [
        'mipush' => [
            'driver' => 'mipush',
            'reg_url' => 'https://api.xmpush.xiaomi.com/v3/message/regid',
            'alias_url' => 'https://api.xmpush.xiaomi.com/v3/message/alias',
            'topic_url' => 'https://api.xmpush.xiaomi.com/v3/message/topic',
            'multi_topic_url' => 'https://api.xmpush.xiaomi.com/v3/message/multi_topic',
            'all_url' => 'https://api.xmpush.xiaomi.com/v3/message/all',
            'exist_url' => 'https://api.xmpush.xiaomi.com/v2/schedule_job/exist',
            'delete_url' => 'https://api.xmpush.xiaomi.com/v2/schedule_job/delete',

            'android' => [
                'bundle_id' => '',
                'app_id' => '',
                'app_key' => '',
                'app_secret' => ''
            ],

            'ios' => [
                'bundle_id' => '',
                'app_id' => '',
                'app_key' => '',
                'app_secret' => ''
            ],
            'prefix' => env( 'MIPUSH_PREFIX' , 'test_' )
        ],
    ],
];

创建message(消息发送只能发给message对应的端), (*16)

    //苹果message -- 具体参数配置清查看小米推送文档
    $message = new \Hht\MiPush\Builder\IOSBuilder();

    //安卓message -- 具体参数配置清查看小米推送文档
    $message = new \Hht\MiPush\Builder\Builder();

根据别名发送 -- 单个(别名会自动添加配置内的前缀)

    Push::launcher('mipush')->setAlias('aaa')->send($message);

根据别名发送 -- 多个(别名会自动添加配置内的前缀)

    Push::launcher('mipush')->setAliases('aaa', 'bbb', 'ccc')->send($message);
    //或
    Push::launcher('mipush')->setAliases(['aaa', 'bbb', 'ccc'])->send($message);

根据id发送 -- 单个

    Push::launcher('mipush')->setId('aaa')->send($message);

根据id发送 -- 多个

    Push::launcher('mipush')->setIds('aaa', 'bbb', 'ccc')->send($message);
    //或
    Push::launcher('mipush')->setIds(['aaa', 'bbb', 'ccc'])->send($message);

根据标签发送(标签发会自动添加配置内的前缀)

    Push::launcher('mipush')->setTopic('aaaa')->send($message);

发给所有用户

    Push::launcher('mipush')->setAll(true)->send($message);

依赖包

  • haiaouang/support : https://github.com/haiaouang/support
  • haiaouang/pusher : https://github.com/haiaouang/pusher

The Versions

21/08 2017

dev-master

9999999-dev https://github.com/haiaouang/mipush

The Hht mipush package.

  Sources   Download

MIT

The Requires

 

by haitaohuang

18/08 2017

1.0.2

1.0.2.0 https://github.com/haiaouang/mipush

The Hht mipush package.

  Sources   Download

MIT

The Requires

 

by haitaohuang