jpush-phonegap-plugin/README.md

95 lines
3.5 KiB
Markdown
Raw Normal View History

2016-04-22 11:22:07 +08:00
# JPush PhoneGap / Cordova Plugin
2016-04-21 20:32:28 +08:00
[![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin)
2016-06-23 13:18:27 +08:00
[![QQ Group](https://img.shields.io/badge/QQ%20Group-413602425-red.svg)]()
[![release](https://img.shields.io/badge/release-2.2.3-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases)
2016-05-10 14:11:29 +08:00
[![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jpush-phonegap-plugin)
2016-04-20 17:22:38 +08:00
[![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
2016-04-22 11:22:07 +08:00
支持 iOS, Android 的 Cordova 推送插件。
2016-07-08 13:26:39 +08:00
> 如需要 IM 功能的插件,可关注 [JMessage PhoneGap Plugin](https://github.com/jpush/jmessage-phonegap-plugin)。
> QQ 交流群413602425
2016-06-12 16:25:11 +08:00
## 集成步骤
2016-06-27 10:34:16 +08:00
集成 JPush PhoneGap Plugin 有两种方法:
2016-01-21 15:15:48 +08:00
2016-06-27 10:34:16 +08:00
### 在线安装
- 通过 Cordova Plugins 安装,要求 PhoneGap/Cordova CLI 5.0+
2016-06-27 10:40:03 +08:00
cordova plugin add jpush-phonegap-plugin --variable API_KEY=your_jpush_appkey
2016-06-27 10:34:16 +08:00
- 直接通过 url 安装:
2016-06-27 10:40:03 +08:00
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable API_KEY=your_jpush_appkey
2016-06-27 10:34:16 +08:00
### 本地安装
2016-06-12 16:25:11 +08:00
使用 git 命令将 JPush PhoneGap 插件下载的本地,目录标记为 $JPUSH_PLUGIN_DIR
2015-12-01 16:06:41 +08:00
2015-12-01 15:40:16 +08:00
git clone https://github.com/jpush/jpush-phonegap-plugin.git
2016-06-12 16:25:11 +08:00
2015-12-01 15:40:16 +08:00
cordova plugin add $JPUSH_PLUGIN_DIR --variable API_KEY=your_jpush_appkey
2016-06-12 16:25:11 +08:00
- [Android 手动安装文档地址](/doc/Android_handle_install.md)。
2016-04-22 11:22:07 +08:00
2016-06-12 16:25:11 +08:00
- [iOS 手动安装文档地址](/doc/iOS_install.md)。
2016-04-22 11:22:07 +08:00
## Demo
2016-06-12 16:25:11 +08:00
插件项目中包含一个简单的 Demo。若想参考可以在 /example 文件夹内找到并拷贝以下文件:
2014-07-10 15:46:30 +08:00
2016-04-22 11:22:07 +08:00
src/example/index.html -> www/index.html
src/example/css/* -> www/css
src/example/js/* -> www/js
2014-07-10 15:46:30 +08:00
2016-04-22 11:22:07 +08:00
## 关于 PhoneGap build 云服务
2014-07-10 15:46:30 +08:00
2016-06-12 16:25:11 +08:00
该项目基于 Cordova 实现,目前无法使用 PhoneGap build 云服务进行打包,建议使用本地环境进行打包。
2016-03-30 22:12:49 +08:00
## API 说明
2016-03-30 22:12:49 +08:00
2016-06-12 16:25:11 +08:00
插件的 API 在 JPushPlugin.js 文件中,该文件的具体位置如下:
### Android
2016-03-30 22:12:49 +08:00
[Project]/assets/www/plugins/cn.jpush.phonegap.JPushPlugin/www
2015-01-16 10:42:06 +08:00
2016-06-12 16:25:11 +08:00
### iOS
2016-03-30 22:12:49 +08:00
[Project]/www/plugins/cn.jpush.phonegap.JPushPlugin/www
2015-01-16 10:42:06 +08:00
### 具体的 API 请参考:
2015-01-16 10:42:06 +08:00
2016-06-12 16:25:11 +08:00
- [公共 API](/doc/Common_detail_api.md)。
2015-01-16 10:42:06 +08:00
2016-06-12 16:25:11 +08:00
- [iOS API](/doc/iOS_API.md)。
2016-06-12 16:25:11 +08:00
- [Android API](/doc/Android_detail_api.md)。
2015-04-14 13:08:41 +08:00
2016-04-22 11:22:07 +08:00
## 常见问题
2016-01-21 15:15:48 +08:00
若要使用 CLI 来编译项目,注意应使用 cordova compile 而不是 cordova build 命令,因为如果修改了插件安装时默认写入到 AndroidManifest.xml
中的代码cordova build 可能会导致对 AndroidManifest.xml 的修改。
2016-06-12 16:25:11 +08:00
Cordova CLI 的具体用法可参考 [Cordova CLI 官方文档](https://cordova.apache.org/docs/en/latest/reference/cordova-cli/index.html)。
2016-04-21 14:51:22 +08:00
2016-04-22 11:22:07 +08:00
### 1. Android
2016-01-21 15:15:48 +08:00
2016-07-13 22:03:35 +08:00
- Eclipse 中 import PhoneGap 工程之后出现:*Type CallbackContext cannot be resolved to a type*。
2016-01-21 15:15:48 +08:00
2016-07-13 22:03:35 +08:00
解决方案Eclipse 中右键单击工程名Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。
2016-04-22 11:22:07 +08:00
### 2. iOS
2016-06-12 16:25:11 +08:00
- 收不到推送:
请首先按照正确方式再次配置证书、描述文件,具体可参考 [iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)。
- 设置 PushConfig.plist
2016-06-12 16:25:11 +08:00
- APP_KEY应用标识。
- CHANNEL渠道标识。
- IsProduction是否生产环境。
- IsIDFA是否使用 IDFA 启动 SDK。
2016-01-21 15:15:48 +08:00
2016-04-22 11:22:07 +08:00
## 更多
2016-07-07 17:54:48 +08:00
- QQ 群413602425。
- [JPush 官网文档](http://docs.jpush.io/)。
- 如有问题可访问[极光社区](http://community.jpush.cn/)。