PHPackages                             garengoh/yii2-xiaomipush - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. garengoh/yii2-xiaomipush

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

garengoh/yii2-xiaomipush
========================

XiaoMiPush for PHP Yii2

09PHPCI failing

Since Dec 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/GarenGoh/yii2-xiaomipush)[ Packagist](https://packagist.org/packages/garengoh/yii2-xiaomipush)[ RSS](/packages/garengoh-yii2-xiaomipush/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

注意
--

[](#注意)

小米推送php SDK(2019年的SDK)存在很多bug,次依赖包修复了其中部分bug.如遇到问题可与我联系

- 邮箱:
- 主页: [wqiang.net](wqiang.net)

配置
--

[](#配置)

```
'xmPushService' => [
     'class' => 'garengoh\xmpush\XiaoMiPush',
     'android_secret' => 'Your android secret.',
     'android_package' => 'Your android package name.',
     'ios_secret' => 'Your ios secret.',
     'ios_bundleId' => 'Your ios bundleId.'
 ]

```

#### 例如

[](#例如)

```
'xmPushService' => [
     'class' => 'garengoh\xmpush\XiaoMiPush',
     'android_secret' => 'CXHodE6CbA+PKG1lEMgzvQ==',
     'android_package' => 'com.wqiang.an',
     'ios_secret' => 'CMHoGE9CbA+PK81lEMgzvQ==',
     'ios_bundleId' => 'cn.wqiang.ii'
 ]

```

如何使用
----

[](#如何使用)

#### 发送安卓消息

[](#发送安卓消息)

```
public function sendAndroid()
{
    $title = '来自小米的推送(安卓)';
    $description = '世界如此大,我想躺床上睡觉';
    $payload = '{"key":12,"name":"wqiang"}';

    // getAndroidSender()方法必须在getMessage()方法之前调用
    $sender =  Yii::$app->xmPushService->getAndroidSender();

    $message = Yii::$app->xmPushService->getMessage(XiaoMiPush::SYSTEM_ANDROID)
        ->notifyType('1,2,4')          //通知类型 可组合 (-1 Default,1 提示音,2 震动,4 呼吸灯)
        ->title($title)                // 通知栏的title
        ->description($description)    // 通知栏的descption
        ->passThrough(0)               // 这是一条通知栏消息，如果需要透传，把这个参数设置成1,同时去掉title和descption两个参数
        ->payload($payload)            // 携带的数据，点击后将会通过客户端的receiver中的onReceiveMessage方法传入。
        ->extra(\xmpush\Builder::notifyForeground, 1)  // 应用在前台是否展示通知，如果不希望应用在前台时候弹出通知，则设置这个参数为0
        //->extra(Builder::notifyEffect, 1)            // 此处设置预定义点击行为,1为打开app
        ->extra('payload', $payload)
        ->notifyId(0)                  // 通知类型。最多支持0-4 5个取值范围，同样的类型的通知会互相覆盖，不同类型可以在通知栏并存
        ->build();                     // build()方法必须放在最后,其他方法顺序可变化

    $result = $sender->sendToAliases($message, [22,11])->getRaw();

    return $result;
}

```

#### 发送IOS消息

[](#发送ios消息)

```
public function sendIos()
{
    $title = '来自小米的推送(IOS)';
    $description = '世界如此大,我想躺床上睡觉';
    $payload = '{"key":12,"name":"wqiang"}';

    // getAndroidSender()方法必须在getMessage()方法之前调用
    // 生产环境需将XiaoMiPush::ENV_DEV改为XiaoMiPush::ENV_PROD
    $sender =  Yii::$app->xmPushService->getIosSender(XiaoMiPush::ENV_DEV);

    $message = Yii::$app->xmPushService->getMessage(XiaoMiPush::SYSTEM_IOS)
       ->parentTitle($title)          // 通知栏的title
       ->description($description)    // 通知栏的descption
       ->soundUrl('default')          // 携带的数据，点击后将会通过客户端的receiver中的onReceiveMessage方法传入。
       ->badge('1');//角标数字
       ->extra('payload', $payload);
       ->build();                     // build()方法必须放在最后,其他方法顺序可变化

    $aliases = [22,11]; // 别名
    // 通过别名发送
    $result = $sender->sendToAliases($message, $aliases)->getRaw();
    // 其他发送方式不再一一举例

    return $result;
}

```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c996cb1d1e4545dd53629caae668fd6a6fe0e48d8623525da74e945c1b2c0b49?d=identicon)[GarenGoh](/maintainers/GarenGoh)

---

Top Contributors

[![GarenGoh](https://avatars.githubusercontent.com/u/13014689?v=4)](https://github.com/GarenGoh "GarenGoh (18 commits)")

### Embed Badge

![Health badge](/badges/garengoh-yii2-xiaomipush/health.svg)

```
[![Health](https://phpackages.com/badges/garengoh-yii2-xiaomipush/health.svg)](https://phpackages.com/packages/garengoh-yii2-xiaomipush)
```

###  Alternatives

[laravel-frontend-presets/tailwindcss

Laravel frontend preset for Tailwind CSS

1.1k405.6k6](/packages/laravel-frontend-presets-tailwindcss)[topthink/think-worker

workerman extend for thinkphp

202227.2k9](/packages/topthink-think-worker)[kartik-v/yii2-field-range

Easily manage Yii 2 ActiveField ranges (from/to) with Bootstrap 3 addons markup and more

232.1M26](/packages/kartik-v-yii2-field-range)[nullref/yii2-datatables

Yii2 Extension for DataTables jQuery plug-in

7290.3k](/packages/nullref-yii2-datatables)[los/basepath

PHP middleware to remove a path prefix from request uri

14132.4k](/packages/los-basepath)[tdwesten/statamic-builder

A fluent blueprint and fieldset builder for Statamic.

3610.3k1](/packages/tdwesten-statamic-builder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
