format .md

This commit is contained in:
Hevin 2016-03-30 22:12:49 +08:00
parent 661b216359
commit cc31bc6b84
6 changed files with 291 additions and 275 deletions

View File

@ -1,9 +1,9 @@
## JPush PhoneGap Plugin ##
jpush-phonegap-plugin 支持 iOS,Android 的推送插件。
JPush-PhoneGap-Plugin 支持 iOS, Android 的推送插件。
**功能特性:**
>+ 发送推送通知
+ 发送推送通知
+ 发送推送自定义消息
+ 设置推送标签和别名
+ 设置角标iOS
@ -28,9 +28,9 @@ jpush-phonegap-plugin 支持 iOS,Android 的推送插件。
然后再执行 `cordova plugin add xxxxx` 命令,不然有一些必须要的链接库需要手动添加
###Cordova CLI/Phonegap 安装 Android & iOS
###Cordova CLI / PhoneGap 安装 Android & iOS
1). 安装JPush PhoneGap Plugin。 有两种方法。
1). 安装 JPush PhoneGap Plugin, 有两种方法:
方法一:在线安装
@ -38,23 +38,21 @@ jpush-phonegap-plugin 支持 iOS,Android 的推送插件。
方法二:下载到本地再安装
使用git命令将jpush phonegap插件下载的本地,将这个目录标记为`$JPUSH_PLUGIN_DIR`
使用 git 命令将 JPush PhoneGap 插件下载的本地,将这个目录标记为 `$JPUSH_PLUGIN_DIR`
git clone https://github.com/jpush/jpush-phonegap-plugin.git
cordova plugin add $JPUSH_PLUGIN_DIR --variable API_KEY=your_jpush_appkey
2). 安装 org.apache.cordova.device
cordova plugin add org.apache.cordova.device
3). 在js中调用函数,初始化jpush sdk
3). 在 js 中调用函数,初始化 JPush SDK
//由于 PhoneGap 插件采用了 Lazy load 的特性,所以建议在 js 文件能执行的最开始就添加
window.plugins.jPushPlugin.init();
//由于phonegap插件采用了Lazy load的特性 所以这里建议在js文件能执行的最开始就加
### Android 手工安装
@ -62,54 +60,60 @@ jpush-phonegap-plugin 支持 iOS,Android 的推送插件。
[Android 手工安装文档地址](document/Android_handle_install.md)
### IOS手工安装
### iOS 手工安装
[IOS手工安装文档地址](document/iOS_handle_install.md)
###示例
1. "$JPUSH_PLUGIN_DIR/example"文件夹内找到并拷贝以下文件
"$JPUSH_PLUGIN_DIR/example"文件夹内找到并拷贝以下文件
src/example/index.html to www/index.html
src/example/css/* to www/css
src/example/js/* to www/js
###关于'phonegap build'云服务
###关于'PhoneGap build'云服务
该项目基于cordova实现目前无法使用'phonegap build'云服务进行打包,建议使用本地环境进行打包
该项目基于 cordova 实现,目前无法使用 'PhoneGap build' 云服务进行打包,建议使用本地环境进行打包
### API 说明
插件的API集中在JPushPlugin.js文件中,这个文件的位置如下
插件的 API 集中在 JPushPlugin.js 文件中,该文件的具体位置如下:
* android:[YOUR__ANDROID_PROJECT]/assets/www/plugins/cn.jpush.phonegap.JPushPlugin/www
* iOS:[YOUR_iOS_PROJEcT]/www/plugins/cn.jpush.phonegap.JPushPlugin/www
Android:
具体的API请参考这里
[Project]/assets/www/plugins/cn.jpush.phonegap.JPushPlugin/www
#### iOS和android通用API简介
iOS:
+ 停止与恢复推送服务 API
[Project]/www/plugins/cn.jpush.phonegap.JPushPlugin/www
具体的 API 请参考下面:
#### iOS 和 Android 通用 API 简介
+ 停止与恢复推送服务
window.plugins.jPushPlugin.init()
window.plugins.jPushPlugin.stopPush()
window.plugins.jPushPlugin.resumePush()
window.plugins.jPushPlugin.isPushStopped(callback)
+ 获取 RegistrationID API
+ 获取 RegistrationID
window.plugins.jPushPlugin.getRegistrationID(callback)
+ 别名与标签 API
+ 别名与标签
window.plugins.jPushPlugin.setTagsWithAlias(tags, alias)
window.plugins.jPushPlugin.setTags(tags)
window.plugins.jPushPlugin.setAlias(alias)
+ 获取点击通知内容
event - jpush.openNotification
+ 获取通知内容
event - jpush.receiveNotification
@ -161,47 +165,44 @@ jpush-phonegap-plugin 支持 iOS,Android 的推送插件。
[iOS API 详细说明](document/iOS_detail_api.md)
#### android API简介
#### Android API简介
+ 获取集成日志
window.plugins.jPushPlugin.setDebugMode(mode)
+ 接收推送消息和点击通知
//下面这两个api 是兼容旧有的代码
//下面这两个 API 是兼容旧有的代码
window.plugins.jPushPlugin.receiveMessageInAndroidCallback(data)
window.plugins.jPushPlugin.openNotificationInAndroidCallback(data)
+ 统计分析 API
+ 统计分析
window.plugins.jPushPlugin.setStatisticsOpen(boolean)
或在 MainActivity 中的 onPause() 和 onResume() 方法中分别调用
JPushInterface.onResume(this) 和 JPushInterface.onPause(this) 来启用统计分析功能,
JPushInterface.onPause(this) 和 JPushInterface.onResume(this) 来启用统计分析功能,
如果使用这种方式启用统计分析功能,则 window.plugins.jPushPlugin.setStatisticsOpen(boolean)
方法不再有效,建议不要同时使用。
+ 清除通知 API
+ 清除通知
window.plugins.jPushPlugin.clearAllNotification()
+ 通知栏样式定制 API
+ 通知栏样式定制
window.plugins.jPushPlugin.setBasicPushNotificationBuilder = function()
window.plugins.jPushPlugin.setCustomPushNotificationBuilder = function()
+ 设置保留最近通知条数 API
+ 设置保留最近通知条数
window.plugins.jPushPlugin.setLatestNotificationNum(num)
+ 本地通知API
+ 本地通知
window.plugins.jPushPlugin.addLocalNotification(builderId,
content,
title,
notificaitonID,
broadcastTime,
extras)
window.plugins.jPushPlugin.addLocalNotification(builderId, content,
title, notificaitonID, broadcastTime, extras)
window.plugins.jPushPlugin.removeLocalNotification(notificationID)
window.plugins.jPushPlugin.clearLocalNotifications()
@ -209,16 +210,17 @@ jpush-phonegap-plugin 支持 iOS,Android 的推送插件。
###常见问题
####1. android
####1. Android
eclipse中phonegap工程import之后出现:`Type CallbackContext cannot be resolved to a type`
解决方案eclipse中右键单击工程名Build Path->Config Build Path->Projects->选中 工程名称CordovaLib->点击 add
eclipse 中 PhoneGap 工程 import 之后出现:`Type CallbackContext cannot be resolved to a type`
解决方案eclipse 中右键单击工程名Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add
####2. iOS 设置 / 修改 APP_KEY
在PushConfig.plist 中修改。PushConfig.plist 其他值说明:
CHANNEL 渠道标识
IsProduction 是否生产环境(暂未启用)
在 PushConfig.plist 中修改。
PushConfig.plist 其他值说明:
CHANNEL: 渠道标识
IsProduction: 是否生产环境(暂未启用)

View File

@ -1,4 +1,4 @@
## adnroid API简介
## Android API简介
@ -6,7 +6,7 @@
#### API - setDebugMode
用于开启调试模式,可以查看集成JPush过程中的log如果集成失败可方便定位问题所在
用于开启调试模式,可以查看集成 JPush 过程中的 Log如果集成失败可方便定位问题所在
##### 接口定义
@ -23,7 +23,7 @@
### 接收消息和点击通知事件
#### API - receiveMessageInAndroidCallback
用于android收到应用内消息的回调函数(请注意和通知的区别),该函数不需要主动调用
用于 Android 收到应用内消息的回调函数(请注意和通知的区别),该函数不需要主动调用
##### 接口定义
@ -36,7 +36,7 @@
#### API - openNotificationInAndroidCallback
当点击android手机的通知栏进入应用程序时,会调用这个函数,这个函数不需要主动调用,是作为回调函数来用的
当点击 Android 手机的通知栏进入应用程序时,会调用这个函数,这个函数不需要主动调用,是作为回调函数来用的
##### 接口定义
@ -51,7 +51,7 @@
### 统计分析 API
#### API - onResume / onPause
这是一个 android local api不是js的api,请注意
这是一个 android local api不是 js 的 API,请注意
本 API 用于“用户使用时长”,“活跃用户”,“用户打开次数”的统计,并上报到服务器,在 Portal 上展示给开发者。
@ -178,11 +178,7 @@
#####接口定义
window.plugins.jPushPlugin.addLocalNotification = function(builderId,
content,
title,
notificaitonID,
broadcastTime,
extras)
content, title, notificaitonID, broadcastTime, extras)
window.plugins.jPushPlugin.removeLocalNotification = function(notificationID)
window.plugins.jPushPlugin.clearLocalNotifications = function()

View File

@ -1,6 +1,6 @@
#Android 手工安装
下载jpush phonegap插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
下载 JPush PhoneGap 插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
1. 复制:`$JPUSH_PLUGIN_DIR`/src/android/*.java 到 cn/jpush/phonega/ 目录下(即cn.jpush.phonegap 的包下)
2. 复制:`$JPUSH_PLUGIN_DIR`/src/android/armeabi/libjpush.so 到 lib/armeabi/
@ -33,16 +33,19 @@
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="cn.jpush.android.ui.PushActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="$PACKAGE_NAME"/>
</intent-filter>
</activity>
<!-- Required SDK 核心功能-->
<service
android:name="cn.jpush.android.service.DownloadService"
android:enabled="true"
android:exported="false">
</service>
<!-- Required SDK 核心功能-->
<service
android:name="cn.jpush.android.service.PushService"
@ -53,22 +56,25 @@
<action android:name="cn.jpush.android.intent.REPORT"/>
<action android:name="cn.jpush.android.intent.PushService"/>
<action android:name="cn.jpush.android.intent.PUSH_TIME"/>
</intent-filter>
</service>
<!-- Required SDK 核心功能-->
<receiver
android:name="cn.jpush.android.service.PushReceiver"
android:enabled="true">
<intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY"/>
<!--Required 显示通知栏 -->
<category android:name="$PACKAGE_NAME"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT"/>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
<!-- Optional -->
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
@ -83,26 +89,39 @@
android:enabled="true">
<intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY"/>
<!-- Required 显示通知栏 -->
<category android:name="$PACKAGE_NAME"/>
</intent-filter>
<intent-filter>
<action android:name="cn.jpush.android.intent.REGISTRATION"/>
<!-- Required 用户注册 SDK 的intent -->
<action android:name="cn.jpush.android.intent.UNREGISTRATION"/>
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED"/>
<!-- Required 用户接收 SDK 消息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED"/>
<!-- Required 用户接收 SDK 通知栏信息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED"/>
<!-- Required 用户打开自定义通知栏的intent -->
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK"/>
<!-- Optional 用户接受 Rich Push Javascript 回调函数的intent -->
<category android:name="$PACKAGE_NAME"/>
</intent-filter>
</receiver>
<!-- Required SDK核心功能-->
<receiver android:name="cn.jpush.android.service.AlarmReceiver"/>
<receiver
android:name="cn.jpush.android.service.AlarmReceiver"/>
<!-- Required. Enable it you can get statistics data with channel -->
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
<meta-data android:name="JPUSH_APPKEY" android:value="299d0fee887820e7d90a68b2"/>
<meta-data
android:name="JPUSH_CHANNEL" android:value="developer-default"/>
<meta-data
android:name="JPUSH_APPKEY" android:value="299d0fee887820e7d90a68b2"/>

View File

@ -25,9 +25,9 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
window.plugins.jPushPlugin.init()
### API - stopPush
+ 在android平台
+ 在 Android 平台
+ 开发者App可以通过调用停止推送服务API来停止极光推送服务。当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。
+ 开发者 App 可以通过调用停止推送服务 API 来停止极光推送服务,当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。
+ 调用了本 API 后JPush 推送服务完全被停止。具体表现为:
@ -40,7 +40,7 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
+ iOS 平台
+ 不推荐调用,因为这个 API 只是让你的 DeviceToken 失效,在 设置-通知 中您的应用程序没有任何变化
+ 推荐:设置一个UI界面 提醒用户在在设置-通知关闭推送服务
+ 推荐:设置一个 UI 界面, 提醒用户在 设置-通知 中关闭推送服务
### 接口定义
@ -52,7 +52,7 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
恢复推送服务。调用了此 API 后
+ 在android平台
+ 在 Android 平台
+ 极光推送完全恢复正常工作,
@ -68,7 +68,7 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
#### API - isPushStopped
+ 在android平台
+ 在 Android 平台
+ 用来检查 Push Service 是否已经被停止
@ -103,7 +103,8 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
RegistrationID 定义
集成了 JPush SDK 的应用程序在第一次成功注册到 JPush 服务器时JPush 服务器会给客户端返回一个唯一的该设备的标识 - RegistrationID。JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
集成了 JPush SDK 的应用程序在第一次成功注册到 JPush 服务器时JPush 服务器会给客户端返回一个唯一的该设备的标识 - RegistrationID。
JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
应用程序可以把此 RegistrationID 保存以自己的应用服务器上,然后就可以根据 RegistrationID 来向设备推送消息或者通知。
@ -122,8 +123,8 @@ RegistrationID 定义
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
var onGetRegistradionID = function(data) {
try {
console.log("JPushPlugin:registrationID is "+data) }
catch(exception){
console.log("JPushPlugin:registrationID is " + data)
} catch(exception) {
console.log(exception);
}
}
@ -136,7 +137,7 @@ RegistrationID 定义
这几个 API 可以在 App 里任何地方调用。
**别名 alias**
**别名 Alias**
为安装了应用程序的用户,取个别名来标识。以后给该用户 Push 消息时,就可以用此别名来指定。
@ -148,7 +149,7 @@ RegistrationID 定义
举例:在一个用户要登录的游戏中,可能设置别名为 userid。游戏运营时发现该用户 3 天没有玩游戏了,则根据 userid 调用服务器端 API 发通知到客户端提醒用户。
**标签 tag**
**标签 Tag**
为安装了应用程序的用户,打上标签。其目的主要是方便开发者根据标签,来批量下发 Push 消息。
@ -172,7 +173,7 @@ RegistrationID 定义
* 每次调用至少设置一个 tag覆盖之前的设置不是新增
* 有效的标签组成:字母(区分大小写)、数字、下划线、汉字
* 限制:每个 tag 命名长度限制为 40 字节,最多支持设置 100 个 tag但总长度不得超过1K字节。判断长度需采用UTF-8编码
* 单个设备最多支持设置 100 个 tagApp 全局 tag 数量无限制。
* 单个设备最多支持设置 100 个 tagApp 全局 tag 数量无限制。
* alias
* 参数类型为字符串
* nil 此次调用不设置此值
@ -192,8 +193,7 @@ RegistrationID 定义
result += "tags:" + event.tags + " ";
result += "alias:" + event.alias + " ";
$("#tagAliasResult").html(result);
}
catch(exception){
} catch(exception) {
console.log(exception)
}
}
@ -231,7 +231,7 @@ RegistrationID 定义
- onOpenNotification需要这样写
var alertContent
var alertContent;
if(device.platform == "Android"){
alertContent = window.plugins.jPushPlugin.openNotification.alert;
}else{
@ -241,7 +241,7 @@ RegistrationID 定义
ps点击通知后传递的 json object 保存在 window.plugins.jPushPlugin.openNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意
+ android
+ Android
{"alert":"ding",
"extras":{
@ -281,7 +281,7 @@ ps点击通知后传递的json object 保存在window.plugins.jPushPlugin.ope
- onReceiveNotification 需要这样写:
var alertContent
var alertContent;
if(device.platform == "Android"){
alertContent = window.plugins.jPushPlugin.receiveNotification.alert;
}else{
@ -291,7 +291,7 @@ ps点击通知后传递的json object 保存在window.plugins.jPushPlugin.ope
ps点击通知后传递的 json object 保存在 window.plugins.jPushPlugin.receiveNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意
+ android
+ Android
{"alert":"ding",
"extras":{
@ -354,7 +354,7 @@ ps点击通知后传递的json object 保存在window.plugins.jPushPlugin.rec
ps点击通知后传递的 json object 保存在 window.plugins.jPushPlugin.receiveMessage直接访问即可字段示例根据实际推送情况可能略有差别请注意
+ android
+ Android
{"message":"今天去哪儿",
"extras"{
@ -372,5 +372,3 @@ ps点击通知后传递的json object 保存在window.plugins.jPushPlugin.rec
"key":"不填写没有"
}
}

View File

@ -35,6 +35,7 @@
window.plugins.jPushPlugin.prototype.beginLogPageView = function(pageName, duration)
#####参数说明
pageName 需要统计页面自定义名称
duration 自定义的页面时间
#####调用说明
应在所有的需要统计得页面得 viewWillAppear 和 viewWillDisappear 加入 startLogPageView 和 stopLogPageView 来统计当前页面的停留时间。
@ -222,7 +223,7 @@ window.plugins.jPushPlugin.setLocation(39.26,115.25);
### 设备平台判断
#### API - isPlatformIOS
API 用于区分iOS、Android平台,以便不同设置
API 用于区分 iOS, Android 平台,以便不同设置
##### 接口定义

View File

@ -1,12 +1,12 @@
### IOS手工安装
### iOS手工安装
下载jpush phonegap插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
下载 JPush PhoneGap 插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
1. 用 xcode 打开 iOS 工程 将 `$JPUSH_PLUGIN_DIR`/src/ios/Plugins/ 拖到 project 中
2. 将 `$JPUSH_PLUGIN_DIR`/src/ios/lib/ 拖到 project 中
4. 添加以下框架打开xocode点击project选择(Target -> Build Phases -> Link Binary With Libraries)
4. 添加以下框架,打开 xcode点击 project选择(Target -> Build Phases -> Link Binary With Libraries)
CFNetwork.framework
CoreFoundation.framework