{"id":14966499,"url":"https://github.com/guanguans/yii-jpush","last_synced_at":"2025-10-25T16:30:51.512Z","repository":{"id":56983521,"uuid":"258963285","full_name":"guanguans/yii-jpush","owner":"guanguans","description":"适配于 Yii 的极光推送 SDK","archived":false,"fork":false,"pushed_at":"2021-07-09T09:07:36.000Z","size":216,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-04T09:07:37.199Z","etag":null,"topics":["jpush","yii","yii-extension"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guanguans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"guanguans","custom":"https://www.guanguans.cn/images/wechat.jpeg"}},"created_at":"2020-04-26T07:04:11.000Z","updated_at":"2022-07-19T08:05:48.000Z","dependencies_parsed_at":"2022-08-21T13:20:11.312Z","dependency_job_id":null,"html_url":"https://github.com/guanguans/yii-jpush","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanguans%2Fyii-jpush","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanguans%2Fyii-jpush/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanguans%2Fyii-jpush/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guanguans%2Fyii-jpush/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guanguans","download_url":"https://codeload.github.com/guanguans/yii-jpush/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238174140,"owners_count":19428631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jpush","yii","yii-extension"],"created_at":"2024-09-24T13:36:29.326Z","updated_at":"2025-10-25T16:30:51.145Z","avatar_url":"https://github.com/guanguans.png","language":"PHP","funding_links":["https://patreon.com/guanguans","https://www.guanguans.cn/images/wechat.jpeg"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eyii-jpush\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e适配于 Yii 的极光推送扩展包\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./docs/usage.png\"\u003e\u003c/p\u003e\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/guanguans/yii-jpush/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/guanguans/yii-jpush/?branch=master)\n[![codecov](https://codecov.io/gh/guanguans/yii-jpush/branch/master/graph/badge.svg)](https://codecov.io/gh/guanguans/yii-jpush)\n[![StyleCI](https://github.styleci.io/repos/258963285/shield?branch=master)](https://github.styleci.io/repos/258963285)\n[![Latest Stable Version](https://poser.pugx.org/guanguans/yii-jpush/v/stable)](https://packagist.org/packages/guanguans/yii-jpush)\n[![Total Downloads](https://poser.pugx.org/guanguans/yii-jpush/downloads)](https://packagist.org/packages/guanguans/yii-jpush)\n[![License](https://poser.pugx.org/guanguans/yii-jpush/license)](https://packagist.org/packages/guanguans/yii-jpush)\n\n## 环境要求\n\n* yii \u003e= 2\n\n## 安装\n\n``` shell\n$ composer require guanguans/yii-jpush --prefer-dist -v\n```\n\n## 配置\n\nYii2 配置文件 `config/main.php` 的 components 中添加:\n\n``` php\n'components' =\u003e [\n    // ...\n    'jpush' =\u003e [\n        'class' =\u003e 'Guanguans\\YiiJpush\\Jpush',\n        'appKey' =\u003e 'xxxxxxxxxxx',\n        'masterSecret' =\u003e 'xxxxxxxxxxx',\n        'logFile' =\u003e './jpush.log', // 可选\n        'retryTimes' =\u003e 3, // 可选\n        'zone' =\u003e 'default', // 可选 [default, bj]\n    ],\n    // ...\n]\n```\n\n## 使用，更多详细文档请参考 [jpush/jpush-api-php-client](https://github.com/jpush/jpush-api-php-client)\n\n### 获取 `JPush\\Client` 实例\n\n``` php\n\u003cphp\nYii::$app-\u003ejpush-\u003eclient\n```\n\n### 简单使用\n\n``` php\n\u003c?php\nYii::$app-\u003ejpush-\u003eclient-\u003epush()\n    -\u003esetPlatform('all')\n    -\u003eaddAllAudience()\n    -\u003esetNotificationAlert('Hello, JPush')\n    -\u003esend();\n```\n\n``` php\n/**\n * @param  string  $content  推送内容\n * @param  array  $ids  推送的id\n * @param  string  $info  业务内容\n * @param  string  $title  推送标题 定向的简单推送 不填\n */\nYii::$app-\u003ejpush-\u003eclient-\u003epush()\n    -\u003esetPlatform(['ios', 'android'])\n    -\u003eaddRegistrationId($ids)\n    -\u003eiosNotification([\n        \"title\" =\u003e $title,\n        \"body\"  =\u003e $content\n    ], [\n        'sound'             =\u003e 'sound.caf',\n        'badge'             =\u003e '+1',\n        'content-available' =\u003e true,\n        'mutable-content'   =\u003e true,\n        'category'          =\u003e 'jiguang',\n        'extras'            =\u003e [\n            'info' =\u003e $info,\n        ],\n    ])\n    -\u003eandroidNotification($content, [\n        'title'  =\u003e $title,\n        'extras' =\u003e [\n            'info' =\u003e $info,\n        ],\n    ])\n    -\u003eoptions([\n        // true 表示推送生产环境，false 表示要推送开发环境；如果不指定则默认为推送开发环境\n        'apns_production' =\u003e false,\n    ])\n    -\u003esend();\n```\n\n### 异常处理\n\n``` php\n\u003c?php\n$pusher = Yii::$app-\u003ejpush-\u003eclient-\u003epush();\n$pusher-\u003esetPlatform('all');\n$pusher-\u003eaddAllAudience();\n$pusher-\u003esetNotificationAlert('Hello, JPush');\ntry {\n    $pusher-\u003esend();\n} catch (\\Exception $e) {\n    // try something else here\n    echo $e;\n}\n```\n\n## 测试\n\n``` shell\n$ composer test\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguanguans%2Fyii-jpush","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguanguans%2Fyii-jpush","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguanguans%2Fyii-jpush/lists"}