{"id":13750192,"url":"https://github.com/jpush/jpush-phonegap-plugin","last_synced_at":"2025-05-14T05:10:32.633Z","repository":{"id":56608302,"uuid":"13640781","full_name":"jpush/jpush-phonegap-plugin","owner":"jpush","description":"JPush's officially supported PhoneGap/Cordova plugin (Android \u0026 iOS).  极光推送官方支持的 PhoneGap/Cordova 插件（Android \u0026 iOS）。","archived":false,"fork":false,"pushed_at":"2025-04-22T09:52:55.000Z","size":115577,"stargazers_count":925,"open_issues_count":46,"forks_count":347,"subscribers_count":70,"default_branch":"master","last_synced_at":"2025-05-08T21:13:09.157Z","etag":null,"topics":["android","cordova-plugin","ios","jpush","phonegap-plugin"],"latest_commit_sha":null,"homepage":"https://docs.jiguang.cn","language":"JavaScript","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/jpush.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-10-17T06:22:12.000Z","updated_at":"2025-04-22T09:51:36.000Z","dependencies_parsed_at":"2024-10-27T05:02:05.334Z","dependency_job_id":"3e0d038b-babb-4478-b0f2-d0ac18feac47","html_url":"https://github.com/jpush/jpush-phonegap-plugin","commit_stats":{"total_commits":544,"total_committers":28,"mean_commits":"19.428571428571427","dds":0.7720588235294118,"last_synced_commit":"679f68c7fd70adf522878befea2f52b3b3f8b0ce"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjpush-phonegap-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjpush-phonegap-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjpush-phonegap-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjpush-phonegap-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpush","download_url":"https://codeload.github.com/jpush/jpush-phonegap-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076848,"owners_count":22010611,"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":["android","cordova-plugin","ios","jpush","phonegap-plugin"],"created_at":"2024-08-03T08:00:23.524Z","updated_at":"2025-05-14T05:10:32.607Z","avatar_url":"https://github.com/jpush.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# JPush PhoneGap / Cordova Plugin\n\n[![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin)\n[![release](https://img.shields.io/badge/release-3.4.1-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases)\n[![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jpush-phonegap-plugin)\n[![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_\u0026is_all=1)\n\n极光官方支持的 cordova 推送插件。\n\n- 如需要 IM 功能的插件，可关注 [jmessage-phonegap-plugin](https://github.com/jpush/jmessage-phonegap-plugin)\n- 如需要短信验证码功能插件，可关注 [cordova-plugin-jsms](https://github.com/jpush/cordova-plugin-jsms)\n- 如需要统计分析功能插件，可关注 [cordova-plugin-janalytics](https://github.com/jpush/cordova-plugin-janalytics)\n\n\u003e注意：插件从 v3.4.0 开始支持 cordova-android 7.0.0，因 cordova-android 7.0.0 修改了 Android 项目结构，因此不兼容之前的版本，升级前请务必注意。\n\u003e\n\u003e如果需要在cordova-android 7.0.0之前版本集成最新插件，参照[这篇文章](https://www.jianshu.com/p/23b117ca27a6)\n\u003e\n\u003e如果需要安装之前版本的插件，请先安装 v1.2.0 以下版本（建议安装 v1.1.12）的 [cordova-plugin-jcore](https://github.com/jpush/cordova-plugin-jcore)，再安装旧版本插件（比如 v3.3.2），否则运行会报错。\n\u003e\n\u003e[Cordova Android版本与原生版本对应表](http://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#requirements-and-support)\n## Install\n\n\u003e 注意：\n\u003e - 应用的包名一定要和 APP_KEY 对应应用的包名一致，否则极光推送服务无法注册成功。\n\u003e - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时，需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。\n\n- 通过 Cordova Plugins 安装，要求 Cordova CLI 5.0+：\n\n  ```shell\n  cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey\n  ```\n\n- 或直接通过 url 安装：\n\n  ```shell\n  cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable APP_KEY=your_jpush_appkey\n  ```\n\n- 或下载到本地安装：\n\n  ```shell\n  cordova plugin add Your_Plugin_Path --variable APP_KEY=your_jpush_appkey\n  ```\n  \n  \n### 参数\n\n  - APP_KEY: 必须设置，JPush 上注册的包名对应的 Appkey\n\n    ```shell\n    --variable APP_KEY=your_jpush_appkey\n    ```\n\n  - CHANNEL: 可以不设置，v3.6.0+ 版本开始支持(Android Only)，方便开发者统计 APK 分发渠道，默认为 developer-default.\n\n    ```shell\n    --variable CHANNEL=your_channel\n    ```\n\n  - 同时动态配置 APP_KEY 和 CHANNEL 示例\n\n    ```shell\n    cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey --variable CHANNEL=your_channel\n    ```\n\n### Ionic\n\n如果使用了 Ionic，可以再安装 @jiguang-ionic/jpush 包，适配 ionic-native：\n\n```shell\nnpm install --save @jiguang-ionic/jpush@1.0.2\n\n# npm install --save @jiguang-ionic/jpush@2.0.0 for ionic4+\n```\n\n然后在 *app.module.ts* 中增加：\n\n```js\n// @jiguang-ionic/jpush@1.0.0+\nimport { JPush } from '@jiguang-ionic/jpush';\n\n// @jiguang-ionic/jpush@2.0.0+\nimport { JPush } from '@jiguang-ionic/jpush/ngx';\n...\n  providers: [\n    ...\n    JPush,\n    ...\n  ]\n```\n\n具体可参考 ./ionic/example 中的文件。\n\n\n## Usage\n\n### API\n\n- [Common](/doc/Common_detail_api.md)\n- [iOS](/doc/iOS_API.md)\n- [Android](/doc/Android_detail_api.md)\n\n### Demo\n\n插件项目中包含一个简单的 Demo。若想参考，可以在 */example* 文件夹内找到并拷贝以下文件:\n\n    example/index.html -\u003e www/index.html\n    example/css/* -\u003e www/css\n    example/js/* -\u003e www/js\n\n### 关于 PhoneGap build 云服务\n\n该项目基于 Cordova 实现，目前无法使用 PhoneGap build 云服务进行打包，建议使用本地环境进行打包。\n\n## FAQ\n\n\u003e 如果遇到了疑问，请优先参考 Demo 和 API 文档。若还无法解决，可到 [Issues](https://github.com/jpush/jpush-phonegap-plugin/issues) 提问。\n\n### Android\n\n#### 在 Eclipse 中 import 工程之后出现：*Type CallbackContext cannot be resolved to a type*\n\n右键单击工程名 -\u003e Build Path -\u003e Config Build Path -\u003e Projects -\u003e 选中工程名称 -\u003e CordovaLib -\u003e 点击 add。\n\n#### 无法获取到 Registration Id\n\n检查 AppKey 和应用包名是否对应、是否调用了 `init` 方法。\n\n#### 如何自定义通知声音？\n\nAndroid 因为各 Rom 的高度定制化，不像 iOS 一样能有一个统一的管理，如果在 Android 中想自定义通知铃声，推荐通过 JPush 推送自定义\n消息，之后在 `jpush.receiveMessage` 事件监听中通过 [Cordova Local-Notification Plugin](https://github.com/katzer/cordova-plugin-local-notifications) 触发通知，再配合 [Cordova Background Plugin](https://github.com/katzer/cordova-plugin-background-mode) 插件保证应用的后台运行。\n\n#### 如何让通知内容像 iOS 一样自动换行展示？\n\n[#267](https://github.com/jpush/jpush-phonegap-plugin/issues/267)\n\n#### 关闭 App 后收不到通知\n\nAndroid 的推送通过长连接的方式实现，只有在保持连接的情况下才能收到通知。而有的第三方 ROM 会限制一般应用服务的自启动，也就是在退出应用后，应用的所有服务均被杀死，且无法自启动，所以就会收不到通知。\n\n目前 JPush 是做了应用互相拉起机制的，也就是当用户打开其他集成了 JPush 的应用时，你的应用也能同时收到推送消息。\n\n如果你的应用希望随时都能收到推送，官方推荐是通过文案的方式引导用户在设置中允许你的应用能够自启动，常见机型的设置方法可以参考[这里](https://docs.jiguang.cn/jpush/client/Android/android_faq/#_2)。\n\n或者自己实现应用保活，网上有很多相关文章（不推荐）。\n\n\u003e 为什么 QQ、微信之类的应用退出后还能够收到通知？因为这些大厂应用，手机厂商默认都会加入自启动白名单中，也不会在应用退出后杀死它们的相关服务。\n\u003e 如果你多加留意，就会发现非大厂的应用如果你一段时间不用都是收不到推送的。\n\n### iOS\n\n#### XCode 10 收不到推送怎么办？\n\n打开 xcode -\u003e file -\u003e WorkSpace Settings… -\u003e Build System 改成 Legacy Build System 然后卸载 App 重新运行。\n\n#### 打包时遇到 i386 打包失败怎么办？\n\n```shell\ncordova platform update ios\n```\n\n#### PushConfig.plist 文件中的字段都是什么意思？\n\n- Appkey：应用标识。\n- Channel：渠道标识。\n- IsProduction：是否生产环境。\n- IsIDFA：是否使用 IDFA 启动 SDK。\n\n#### 刚集成完插件收不到推送怎么办？\n\n请首先按照正确方式再次配置证书、描述文件，具体可参考 [iOS 证书设置指南](https://docs.jiguang.cn/jpush/client/iOS/ios_cer_guide/)。\n\n#### iOS 集成插件白屏、或无法启动插件、或打包报错无法找到需要引入的文件怎么办？\n\n按照以下步骤逐个尝试：\n\n- 升级至最新版本 Xcode\n- 删除插件、再重装插件（先使用 `cordova platform add ios`，后使用 `cordova plugin add`）\n\n## Support\n\n- QQ 群：413602425 / 524248013\n- [JPush 官网文档](https://docs.jiguang.cn/jpush/guideline/intro/)\n- [极光社区](http://community.jiguang.cn/)\n\n## Contribute\n\nPlease contribute! [Look at the issues](https://github.com/jpush/jpush-phonegap-plugin/issues).\n\n## License\n\nMIT © [JiGuang](/license)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpush%2Fjpush-phonegap-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpush%2Fjpush-phonegap-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpush%2Fjpush-phonegap-plugin/lists"}