Merge branch 'dev'

This commit is contained in:
Hevin 2017-09-22 21:16:11 +08:00
commit 592d5a5fb9
3 changed files with 234 additions and 408 deletions

View File

@ -13,7 +13,6 @@
- [通知栏样式定制](#通知栏样式定制) - [通知栏样式定制](#通知栏样式定制)
- [设置保留最近通知条数](#设置保留最近通知条数) - [设置保留最近通知条数](#设置保留最近通知条数)
- [本地通知](#本地通知) - [本地通知](#本地通知)
- [富媒体页面 JavaScript 回调 API](#富媒体页面-javascript-回调-api)
## 注册成功事件 ## 注册成功事件
### jpush.receiveRegistrationId ### jpush.receiveRegistrationId
@ -21,7 +20,8 @@
就会触发这个事件(注意只有第一次会触发该事件,之后如果想要取到 registrationId可以直接调用 *getRegistrationID* 方法)。 就会触发这个事件(注意只有第一次会触发该事件,之后如果想要取到 registrationId可以直接调用 *getRegistrationID* 方法)。
#### 代码示例 #### 代码示例
```Javascript
```js
document.addEventListener('jpush.receiveRegistrationId', function (event) { document.addEventListener('jpush.receiveRegistrationId', function (event) {
console.log(event.registrationId) console.log(event.registrationId)
}, false) }, false)
@ -30,27 +30,27 @@ document.addEventListener('jpush.receiveRegistrationId', function (event) {
## 接收通知时获得通知的内容 ## 接收通知时获得通知的内容
- 内容: - 内容:
window.plugins.jPushPlugin.receiveNotification.alert window.JPush.receiveNotification.alert
- 标题: - 标题:
window.plugins.jPushPlugin.receiveNotification.title window.JPush.receiveNotification.title
- 附加字段: - 附加字段:
window.plugins.jPushPlugin.receiveNotification.extras.yourKey window.JPush.receiveNotification.extras.yourKey
## 打开通知时获得通知的内容 ## 打开通知时获得通知的内容
- 内容: - 内容:
window.plugins.jPushPlugin.openNotification.alert window.JPush.openNotification.alert
- 标题: - 标题:
window.plugins.jPushPlugin.openNotification.title window.JPush.openNotification.title
- 附加字段 - 附加字段
window.plugins.jPushPlugin.openNotification.extras.yourKey window.JPush.openNotification.extras.yourKey
## 收到自定义消息时获取消息的内容 ## 收到自定义消息时获取消息的内容
- 内容: - 内容:
window.plugins.jPushPlugin.receiveMessage.message window.JPush.receiveMessage.message
- 附加字段: - 附加字段:
window.plugins.jPushPlugin.receiveMessage.extras.yourKey window.JPush.receiveMessage.extras.yourKey
## 获取集成日志(同时适用于 iOS ## 获取集成日志(同时适用于 iOS
@ -60,7 +60,9 @@ document.addEventListener('jpush.receiveRegistrationId', function (event) {
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.setDebugMode(mode) ```js
window.JPush.setDebugMode(mode)
```
#### 参数说明 #### 参数说明
@ -68,94 +70,20 @@ document.addEventListener('jpush.receiveRegistrationId', function (event) {
- true 显示集成日志。 - true 显示集成日志。
- false 不显示集成日志。 - false 不显示集成日志。
## 接收消息和点击通知事件
### API - receiveMessageInAndroidCallback
用于 Android 收到应用内消息的回调函数(请注意和通知的区别),该函数不需要主动调用。
#### 接口定义
window.plugins.jPushPlugin.receiveMessageInAndroidCallback(data)
#### 参数说明
- data: 接收到的 js 字符串,包含的 key:value 请进入该函数体查看。
### API - openNotificationInAndroidCallback
当点击 Android 手机的通知栏进入应用程序时,会调用这个函数,这个函数不需要主动调用,是作为回调函数来用的。
#### 接口定义
window.plugins.jPushPlugin.openNotificationInAndroidCallback(data)
#### 参数说明
- data: js 字符串。
## 统计分析
### API - onResume / onPause
这是一个 Android Local API不是 js 的 API请注意。
本 API 用于“用户使用时长”,“活跃用户”,“用户打开次数”的统计,并上报到服务器,在 Portal 上展示给开发者。
#### 接口定义
public static void onResume(final Activity activity)
public static void onPause(final Activity activity)
#### 参数说明
- Activity: 当前所在的 Activity。
#### 调用说明
应在所有的 Activity 的 onResume / onPause 方法里调用。
#### 代码示例
@Override
protected void onResume() {
super.onResume();
JPushInterface.onResume(this);
}
@Override
protected void onPause() {
super.onPause();
JPushInterface.onPause(this);
}
### API - setStatisticsOpen
用于在 js 中控制是否打开应用的统计分析功能,但如果已经添加了上面的 onResume / onPause 方法,
就不能再通过这个方法来控制统计分析功能了。
#### 接口定义
window.plugins.jPushPlugin.setStatisticsOpen(boolean)
#### 参数说明
- boolean:
- true: 打开统计分析功能。
- false: 关闭统计分析功能。
### API - reportNotificationOpened ### API - reportNotificationOpened
用于上报用户的通知栏被打开,或者用于上报用户自定义消息被展示等客户端需要统计的事件。 用于上报用户的通知栏被打开,或者用于上报用户自定义消息被展示等客户端需要统计的事件。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.reportNotificationOpened(msgID) ```js
window.JPush.reportNotificationOpened(msgID)
```
#### 参数说明 #### 参数说明
- msgID: 收到的通知或者自定义消息的 id。 - msgID: 收到的通知或者自定义消息的 id。
## 清除通知 ## 清除通知
### API - clearAllNotification ### API - clearAllNotification
@ -166,34 +94,44 @@ document.addEventListener('jpush.receiveRegistrationId', function (event) {
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.clearAllNotification() ```js
window.JPush.clearAllNotification()
```
### API - clearNotificationById ### API - clearNotificationById
根据通知 Id 清除通知(包括本地通知)。 根据通知 Id 清除通知(包括本地通知)。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.clearNotificationById(notificationId) ```js
window.JPush.clearNotificationById(notificationId)
```
#### 参数说明 #### 参数说明
- notificationIdint通知的 id。 - notificationIdint通知的 id。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.clearNotificationById(1) ```js
window.JPush.clearNotificationById(1)
```
## 设置允许推送时间 ## 设置允许推送时间
### API - setPushTime ### API - setPushTime
默认情况下用户在任何时间都允许推送。即任何时候有推送下来,客户端都会收到,并展示。 默认情况下用户在任何时间都允许推送。即任何时候有推送下来,客户端都会收到,并展示。
开发者可以调用此 API 来设置允许推送的时间。 开发者可以调用此 API 来设置允许推送的时间。
如果不在该时间段内收到消息,当前的行为是:推送到的通知会被扔掉。 如果不在该时间段内收到消息,当前的行为是:推送到的通知会被扔掉。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.setPushTime(days, startHour, endHour) ```js
window.JPush.setPushTime(days, startHour, endHour)
```
#### 参数说明 #### 参数说明
- days: 数组0 表示星期天1 表示星期一以此类推7天制数组中值的范围为 0 到 6 )。 - days: 数组0 表示星期天1 表示星期一以此类推7天制数组中值的范围为 0 到 6 )。
数组的值为 null, 表示任何时间都可以收到消息和通知,数组的 size 为 0则表示任何时间都收不到消息和通知。 数组的值为 null, 表示任何时间都可以收到消息和通知,数组的 size 为 0则表示任何时间都收不到消息和通知。
- startHour: 整形,允许推送的开始时间 24 小时制startHour 的范围为 0 到 23 - startHour: 整形,允许推送的开始时间 24 小时制startHour 的范围为 0 到 23
@ -208,7 +146,9 @@ document.addEventListener('jpush.receiveRegistrationId', function (event) {
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.setSilenceTime(startHour, startMinute, endHour, endMinute) ```js
window.JPush.setSilenceTime(startHour, startMinute, endHour, endMinute)
```
#### 参数说明 #### 参数说明
@ -217,7 +157,6 @@ document.addEventListener('jpush.receiveRegistrationId', function (event) {
- endHour: 整形,静音时段的结束时间 - 小时 24小时制范围0~23 )。 - endHour: 整形,静音时段的结束时间 - 小时 24小时制范围0~23 )。
- endMinute: 整形,静音时段的结束时间 - 分钟范围0~59 )。 - endMinute: 整形,静音时段的结束时间 - 分钟范围0~59 )。
## 通知栏样式定制 ## 通知栏样式定制
### API - setBasicPushNotificationBuilder, setCustomPushNotificationBuilder ### API - setBasicPushNotificationBuilder, setCustomPushNotificationBuilder
@ -238,9 +177,10 @@ JPush SDK 提供了 2 个用于定制通知栏样式的构建类:
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.setBasicPushNotificationBuilder() ```js
window.plugins.jPushPlugin.setCustomPushNotificationBuilder() window.JPush.setBasicPushNotificationBuilder()
window.JPush.setCustomPushNotificationBuilder()
```
## 设置保留最近通知条数 ## 设置保留最近通知条数
@ -252,13 +192,14 @@ JPush SDK 提供了 2 个用于定制通知栏样式的构建类:
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.setLatestNotificationNum(num) ```js
window.JPush.setLatestNotificationNum(num)
```
#### 参数说明 #### 参数说明
- num: 保存的条数。 - num: 保存的条数。
## 本地通知 ## 本地通知
### API - addLocalNotification, removeLocalNotification, clearLocalNotifications ### API - addLocalNotification, removeLocalNotification, clearLocalNotifications
本地通知 API 不依赖于网络,无网条件下依旧可以触发。 本地通知 API 不依赖于网络,无网条件下依旧可以触发。
@ -271,77 +212,17 @@ JPush SDK 提供了 2 个用于定制通知栏样式的构建类:
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.addLocalNotification(builderId, content, title, ```js
notificaitonID, broadcastTime, extras) window.JPush.addLocalNotification(builderId, content, title, notificationID, broadcastTime, extras)
window.plugins.jPushPlugin.removeLocalNotification(notificationID) window.JPush.removeLocalNotification(notificationID)
window.plugins.jPushPlugin.clearLocalNotifications() // 同时适用于 iOS window.JPush.clearLocalNotifications() // 同时适用于 iOS
```
#### 参数说明 #### 参数说明
- builderId: 设置本地通知样式。 - builderId: 设置本地通知样式。
- content: 设置本地通知的 content。 - content: 设置本地通知的 content。
- title: 设置本地通知的 title。 - title: 设置本地通知的 title。
- notificaitonID: 设置本地通知的 ID不要为 0 - notificationID: 设置本地通知的 ID不要为 0
- broadcastTime: 设置本地通知触发时间,为距离当前时间的数值,单位是毫秒。 - broadcastTime: 设置本地通知触发时间,为距离当前时间的数值,单位是毫秒。
- extras: 设置额外的数据信息 extras 为 json 字符串。 - extras: 设置额外的数据信息 extras 为 json 字符串。
## 富媒体页面 JavaScript 回调 API
富媒体推送通知时用户可以用自定义的Javascript 函数来控制页面,如关闭当前页面,点击按钮跳转到指定的 Activity通知应用程序做一些指定的动作等。
此 API 提供的回调函数包括:关闭当前页面、打开应用的主 Activity、根据 Activity 名字打开对应的 Activity、以广播的形式传递页面参数到应用程序等功能。
### API - 关闭当前页面
JPushWeb.close(); // 在富文本 HTML 页面中调用后会关闭当前页面。
### API - 打开主 Activity
JPushWeb.startMainActivity(String params);
在HTML中调用此函数后,会打开程序的主Activity 并在对应的 Intent 传入参数 ”params“ Key 为 JPushInterface.EXTRA_EXTRA。
对应 Activity 获取 params 示例代码:
Intent intent = getIntent();
if (null != intent ) {
String params = intent.getStringExtra(JPushInterface.EXTRA_EXTRA);
}
### API - 触发应用中的操作
JPushWeb.triggerNativeAction(String params);
调用了该方法后需要在 MyReceiver.java 中实现后面的业务逻辑:
if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
Log.d(TAG, "用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容触发客户端动作比如打开新的Activity 、打开一个网页等。
}
#### 代码示例
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JPush Webview Test</title>
<script>
function clickButton() {
JPushWeb.close();
}
function openUrl() {
var json = "{'action':'open', 'url':'www.jpush.cn'}";
JPushWeb.triggerNativeAction(json);
JPushWeb.close(); //客服端在广播中收到json 后可以打开对应的URL。
}
</script>
</head>
<body>
<button onclick="javascript:clickButton(this);return false;">Close</button>
<button onclick="javascript:JPushWeb.startMainActivity('test - startMainActivity');return false;">StartMainActivity</button>
<button onclick="javascript:JPushWeb.triggerNativeAction('test - triggerNativeAction');Javascript:JPushWeb.close();">triggerNativeAction and Close current webwiew</button>
<button onclick="javascript:JPushWeb.startActivityByName('com.example.jpushdemo.TestActivity','test - startActivityByName');">startActivityByName</button>
<button onclick="javascript:openUrl();">open a url</button>
</body>
</html>

View File

@ -28,20 +28,17 @@ window.JPush.init()
``` ```
### API - stopPush ### API - stopPush
+ Android 平台:
+ 开发者 App 可以通过调用停止推送服务 API 来停止极光推送服务,当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。 - Android:
- 开发者 App 可以通过调用停止推送服务 API 来停止极光推送服务,当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。
- 调用了本 API 后JPush 推送服务完全被停止,具体表现为:
- JPush Service 不在后台运行。
- 收不到推送消息。
- 不能通过 `init` 方法恢复,而需要调用 `resumePush` 恢复。
- 极光推送其他所有的 API 调用都无效。
+ 调用了本 API 后JPush 推送服务完全被停止,具体表现为: - iOS:
- 不推荐调用,因为这个 API 只是让你的 DeviceToken 失效,在 设置-通知 中您的应用程序没有任何变化。**建议设置一个 UI 界面, 提醒用户在 设置-通知 中关闭推送服务**。
+ JPush Service 不在后台运行。
+ 收不到推送消息。
+ 不能通过 JPushInterface.init 恢复,需要调用 resumePush 恢复。
+ 极光推送所有的其他 API 调用都无效。
+ iOS 平台:
+ 不推荐调用,因为这个 API 只是让你的 DeviceToken 失效,在 设置-通知 中您的应用程序没有任何变化。**建议设置一个 UI 界面, 提醒用户在 设置-通知 中关闭推送服务**。
#### 接口定义 #### 接口定义
@ -53,27 +50,25 @@ window.JPush.stopPush()
恢复推送服务。调用了此 API 后: 恢复推送服务。调用了此 API 后:
+ Android 平台: - Android 平台:
- 极光推送完全恢复正常工作。
+ 极光推送完全恢复正常工作。 - iOS 平台:
- 重新去 APNS 注册。
+ iOS 平台:
+ 重新去 APNS 注册。
#### 接口定义 #### 接口定义
```js
window.JPush.resumePush() window.JPush.resumePush()
```
### API - isPushStopped ### API - isPushStopped
+ Android 平台: - Android 平台:
- 用来检查 Push Service 是否已经被停止。
+ 用来检查 Push Service 是否已经被停止。 - iOS 平台:
- 平台检查推送服务是否注册。
+ iOS 平台:
+ 平台检查推送服务是否注册。
#### 接口定义 #### 接口定义
@ -123,7 +118,9 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
#### 接口定义 #### 接口定义
```js
window.JPush.getRegistrationID(callback) window.JPush.getRegistrationID(callback)
```
#### 返回值 #### 返回值
@ -370,6 +367,7 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js
document.addEventListener("jpush.openNotification", function (event) { document.addEventListener("jpush.openNotification", function (event) {
var alertContent var alertContent
if(device.platform == "Android") { if(device.platform == "Android") {
@ -378,11 +376,13 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
alertContent = event.aps.alert alertContent = event.aps.alert
} }
}, false) }, false)
```
> ps点击通知后传递的 json object 保存在 window.JPush.openNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意。 > ps点击通知后传递的 json object 保存在 window.JPush.openNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意。
+ Android: - Android:
```json
{ {
"title": "title", "title": "title",
"alert":"ding", "alert":"ding",
@ -397,9 +397,11 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
"cn.jpush.android.NOTIFICATION_TYPE": "0" "cn.jpush.android.NOTIFICATION_TYPE": "0"
} }
} }
```
+ iOS: - iOS:
```json
{ {
"aps": { "aps": {
"badge": 1, "badge": 1,
@ -410,6 +412,7 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
"key2": "value2", "key2": "value2",
"_j_msgid": 154604475 "_j_msgid": 154604475
} }
```
## 获取通知内容 ## 获取通知内容
@ -421,6 +424,7 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js
document.addEventListener("jpush.receiveNotification", function (event) { document.addEventListener("jpush.receiveNotification", function (event) {
var alertContent var alertContent
if(device.platform == "Android") { if(device.platform == "Android") {
@ -428,14 +432,15 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
} else { } else {
alertContent = event.aps.alert alertContent = event.aps.alert
} }
alert("open Notificaiton:" + alertContent) alert("open Notification:" + alertContent)
}, false) }, false)
```
> ps点击通知后传递的 json object 保存在 window.JPush.receiveNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意。 > ps点击通知后传递的 json object 保存在 window.JPush.receiveNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意。
+ Android: - Android:
```json
{ {
"title": "title", "title": "title",
"alert":"ding", "alert":"ding",
@ -450,9 +455,11 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
"cn.jpush.android.NOTIFICATION_TYPE":"0" "cn.jpush.android.NOTIFICATION_TYPE":"0"
} }
} }
```
+ iOS: - iOS:
```json
{ {
"aps":{ "aps":{
"badge":1, "badge":1,
@ -463,7 +470,7 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
"key2":"value2", "key2":"value2",
"_j_msgid":154604475 "_j_msgid":154604475
} }
```
## 获取自定义消息推送内容 ## 获取自定义消息推送内容
@ -471,12 +478,13 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
收到自定义消息时触发这个事件,推荐使用事件的方式传递。 收到自定义消息时触发这个事件,推荐使用事件的方式传递。
但同时保留了 receiveMessageIniOSCallback 的回调函数,兼容以前的代码。 但同时保留了 `receiveMessageIniOSCallback` 的回调函数,兼容以前的代码。
#### 代码示例 #### 代码示例
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js
document.addEventListener("jpush.receiveMessage", function (event) { document.addEventListener("jpush.receiveMessage", function (event) {
var message var message
if(device.platform == "Android") { if(device.platform == "Android") {
@ -485,27 +493,32 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
message = event.content; message = event.content;
} }
}, false) }, false)
```
> ps点击通知后传递的 json object 保存在 window.JPush.receiveMessage直接访问即可字段示例根据实际推送情况可能略有差别请注意。 > ps点击通知后传递的 json object 保存在 window.JPush.receiveMessage直接访问即可字段示例根据实际推送情况可能略有差别请注意。
+ Android: - Android:
```json
{ {
"message":"今天去哪儿", "message":"今天去哪儿",
"extras"{ "extras"{
"yourKey": "yourValue", "yourKey": "yourValue",
"cn.jpush.android.MSG_ID":"154378013", "cn.jpush.android.MSG_ID":"154378013",
"cn.jpush.android.CONTENT_TYPE":"", "cn.jpush.android.CONTENT_TYPE":"",
"cn.jpush.android.EXTRA":{"key":"不添没有"} "cn.jpush.android.EXTRA":{ "key":"不添加没有" }
} }
} }
```
+ iOS - iOS
```json
{ {
"content":"今天去哪儿", "content":"今天去哪儿",
"extras":{"key":"不填写没有"} "extras":{ "key":"不添加没有" }
} }
```
## 判断系统设置中是否允许当前应用推送 ## 判断系统设置中是否允许当前应用推送
### API - getUserNotificationSettings ### API - getUserNotificationSettings
@ -523,9 +536,11 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
#### 代码示例 #### 代码示例
```js
window.JPush.getUserNotificationSettings(function(result) { window.JPush.getUserNotificationSettings(function(result) {
if(result == 0) { if(result == 0) {
// 系统设置中已关闭应用推送。 // 系统设置中已关闭应用推送。
} else if(result > 0) { } else if(result > 0) {
// 系统设置中打开了应用推送。 // 系统设置中打开了应用推送。
}) })
```

View File

@ -3,7 +3,6 @@
- [延迟注册和启动推送通知服务](#延迟注册和启动推送通知服务) - [延迟注册和启动推送通知服务](#延迟注册和启动推送通知服务)
- [开始与停止推送服务](#开始与停止推送服务) - [开始与停止推送服务](#开始与停止推送服务)
- [获取 RegistrationID](#获取-registrationid) - [获取 RegistrationID](#获取-registrationid)
- [别名与标签](#别名与标签)
- [获取 APNS 推送内容](#获取-apns-推送内容) - [获取 APNS 推送内容](#获取-apns-推送内容)
- [点击推送通知](#点击推送通知) - [点击推送通知](#点击推送通知)
- [前台收到推送](#前台收到推送) - [前台收到推送](#前台收到推送)
@ -39,7 +38,7 @@
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.startJPushSDK() window.JPush.startJPushSDK()
``` ```
## 开始与停止推送服务 ## 开始与停止推送服务
@ -59,7 +58,7 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.init() window.JPush.init()
``` ```
### API - stopPush ### API - stopPush
@ -70,7 +69,7 @@ window.plugins.jPushPlugin.init()
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.stopPush() window.JPush.stopPush()
``` ```
### API - resumePush ### API - resumePush
@ -80,7 +79,7 @@ window.plugins.jPushPlugin.stopPush()
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.resumePush() window.JPush.resumePush()
``` ```
### API - isPushStopped ### API - isPushStopped
@ -90,7 +89,7 @@ iOS平台检查推送服务是否停止。
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.isPushStopped(callback) window.JPush.isPushStopped(callback)
``` ```
#### 参数说明 #### 参数说明
@ -100,7 +99,7 @@ window.plugins.jPushPlugin.isPushStopped(callback)
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.isPushStopped(function(data) { window.JPush.isPushStopped(function(data) {
if(data > 0) { if(data > 0) {
// 已关闭 // 已关闭
} else { } else {
@ -133,80 +132,11 @@ JPushPlugin.getRegistrationID(callback)
#### 调用示例 #### 调用示例
```js ```js
window.plugins.jPushPlugin.getRegistrationID(function(data) { window.JPush.getRegistrationID(function(data) {
console.log("JPushPlugin:registrationID is " + data) console.log("JPushPlugin:registrationID is " + data)
}) })
``` ```
## 别名与标签
### API - setTagsWithAlias, setTags, setAlias
提供几个相关 API 用来设置别名alias与标签tags
这几个 API 可以在 App 里任何地方调用。
**别名 Alias**
为安装了应用程序的用户,取个别名来标识。以后给该用户 Push 消息时,就可以用此别名来指定。
每个用户只能指定一个别名。
同一个应用程序内,对不同的用户,建议取不同的别名。这样,尽可能根据别名来唯一确定用户。
系统不限定一个别名只能指定一个用户。如果一个别名被指定到了多个用户,当给指定这个别名发消息时,服务器端 API 会同时给这多个用户发送消息。
举例:在一个用户要登录的游戏中,可能设置别名为 userId。游戏运营时发现该用户 3 天没有玩游戏了,则根据 userId 调用服务器端 API 发通知到客户端提醒用户。
**标签 Tag**
为安装了应用程序的用户,打上标签。其目的主要是方便开发者根据标签,来批量下发 Push 消息。
可为每个用户打多个标签。
不同应用程序、不同的用户,可以打同样的标签。
举例: game, old_page, women。
#### 接口定义
```js
window.plugins.jPushPlugin.setTagsWithAlias(tags, alias, successCallback, errorCallback)
window.plugins.jPushPlugin.setTags(tags, successCallback)
window.plugins.jPushPlugin.setAlias(alias, errorCallback)
```
#### 参数说明
- tags:
- 参数类型为数组。
- nil 此次调用不设置此值。
- 空集合表示取消之前的设置。
- 每次调用至少设置一个 tag覆盖之前的设置不是新增。
- 有效的标签组成:字母(区分大小写)、数字、下划线、汉字。
- 限制:每个 tag 命名长度限制为 40 字节,最多支持设置 100 个 tag但总长度不得超过1K字节判断长度需采用UTF-8编码
- 单个设备最多支持设置 100 个 tagApp 全局 tag 数量无限制。
- alias:
- 参数类型为字符串。
- nil 此次调用不设置此值。
- 空字符串 "")表示取消之前的设置。
- 有效的别名组成:字母(区分大小写)、数字、下划线、汉字。
- 限制alias 命名长度限制为 40 字节(判断长度需采用 UTF-8 编码)。
#### 错误码定义
| Code | 描述 | 详细解释 |
| ---- | :-------------------------- | :-------------------------------- |
| 6001 | 无效的设置tag/alias 不应参数都为 null | |
| 6002 | 设置超时 | 建议重试。 |
| 6003 | alias 字符串不合法 | 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。 |
| 6004 | alias超长 | 最多 40 个字节(中文 UTF-8 是 3 个字节)。 |
| 6005 | 某一个 tag 字符串不合法 | 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。 |
| 6006 | 某一个 tag 超长 | 一个 tag 最多 40 个字节(中文 UTF-8 是 3 个字节)。 |
| 6007 | tags 数量超出限制(最多 100 个) | 这是一台设备的限制。一个应用全局的标签数量无限制。 |
| 6008 | tag/alias 超出总长度限制 | 总长度最多 1K 字节。 |
| 6011 | 10 秒内设置 tag 或 alias 大于 3 次 | 短时间内操作过于频繁。 |
## 获取 APNS 推送内容 ## 获取 APNS 推送内容
### 点击推送通知 ### 点击推送通知
@ -372,8 +302,8 @@ JPush 封装 badge 功能,允许应用上传 badge 值至 JPush 服务器,
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.setBadge(value) window.JPush.setBadge(value)
window.plugins.jPushPlugin.resetBadge() window.JPush.resetBadge()
``` ```
`resetBadge` 相当于 `setBadge(0)` `resetBadge` 相当于 `setBadge(0)`
@ -389,8 +319,8 @@ value 取值范围0 ~ 99999。
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.setBadge(5) window.JPush.setBadge(5)
window.plugins.jPushPlugin.resetBadge() window.JPush.resetBadge()
``` ```
### API - setApplicationIconBadgeNumber ### API - setApplicationIconBadgeNumber
@ -400,7 +330,7 @@ window.plugins.jPushPlugin.resetBadge()
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(badge) window.JPush.setApplicationIconBadgeNumber(badge)
``` ```
#### 参数说明 #### 参数说明
@ -410,7 +340,7 @@ window.plugins.jPushPlugin.setApplicationIconBadgeNumber(badge)
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0) window.JPush.setApplicationIconBadgeNumber(0)
``` ```
### API - getApplicationIconBadgeNumber ### API - getApplicationIconBadgeNumber
@ -420,7 +350,7 @@ window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0)
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.getApplicationIconBadgeNumber(callback) window.JPush.getApplicationIconBadgeNumber(callback)
``` ```
#### 参数说明 #### 参数说明
@ -430,7 +360,7 @@ window.plugins.jPushPlugin.getApplicationIconBadgeNumber(callback)
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(badgeNum) { window.JPush.getApplicationIconBadgeNumber(function(badgeNum) {
console.log(badgeNum) console.log(badgeNum)
}) })
``` ```
@ -444,7 +374,7 @@ window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(badgeNum) {
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.addLocalNotificationForIOS(delayTime, content, badge, notificationID, extras) window.JPush.addLocalNotificationForIOS(delayTime, content, badge, notificationID, extras)
``` ```
#### 参数说明 #### 参数说明
@ -458,7 +388,7 @@ window.plugins.jPushPlugin.addLocalNotificationForIOS(delayTime, content, badge,
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.addLocalNotificationForIOS(24*60*60, "本地推送内容", 1, "notiId", {"key":"value"}); window.JPush.addLocalNotificationForIOS(24*60*60, "本地推送内容", 1, "notiId", {"key":"value"});
``` ```
### API - deleteLocalNotificationWithIdentifierKeyInIOS ### API - deleteLocalNotificationWithIdentifierKeyInIOS
@ -468,7 +398,7 @@ window.plugins.jPushPlugin.addLocalNotificationForIOS(24*60*60, "本地推送内
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey) window.JPush.deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey)
``` ```
#### 参数说明 #### 参数说明
@ -478,7 +408,7 @@ window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS(identif
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS("identifier") window.JPush.deleteLocalNotificationWithIdentifierKeyInIOS("identifier")
``` ```
### API - clearAllLocalNotifications ### API - clearAllLocalNotifications
@ -488,13 +418,13 @@ window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS("identi
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.clearAllLocalNotifications() window.JPush.clearAllLocalNotifications()
``` ```
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.clearAllLocalNotifications() window.JPush.clearAllLocalNotifications()
``` ```
## 获取本地通知内容 ## 获取本地通知内容
@ -521,9 +451,9 @@ window.plugins.jPushPlugin.clearAllLocalNotifications()
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.startLogPageView(pageName) window.JPush.startLogPageView(pageName)
window.plugins.jPushPlugin.stopLogPageView(pageName) window.JPush.stopLogPageView(pageName)
window.plugins.jPushPlugin.beginLogPageView(pageName, duration) window.JPush.beginLogPageView(pageName, duration)
``` ```
#### 参数说明 #### 参数说明
@ -540,9 +470,9 @@ window.plugins.jPushPlugin.beginLogPageView(pageName, duration)
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.beginLogPageView("newPage", 5); window.JPush.beginLogPageView("newPage", 5);
window.plugins.jPushPlugin.startLogPageView("onePage"); window.JPush.startLogPageView("onePage");
window.plugins.jPushPlugin.stopLogPageView("onePage"); window.JPush.stopLogPageView("onePage");
``` ```
## 日志等级设置 ## 日志等级设置
@ -556,7 +486,7 @@ window.plugins.jPushPlugin.stopLogPageView("onePage");
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.setDebugModeFromIos(); window.JPush.setDebugModeFromIos();
``` ```
### API - setLogOFF ### API - setLogOFF
@ -568,7 +498,7 @@ window.plugins.jPushPlugin.setDebugModeFromIos();
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.setLogOFF(); window.JPush.setLogOFF();
``` ```
### API - setCrashLogON ### API - setCrashLogON
@ -580,7 +510,7 @@ window.plugins.jPushPlugin.setLogOFF();
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.setCrashLogON(); window.JPush.setCrashLogON();
``` ```
## 地理位置上报 ## 地理位置上报
@ -592,7 +522,7 @@ window.plugins.jPushPlugin.setCrashLogON();
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.prototype.setLocation(latitude, longitude) window.JPush.prototype.setLocation(latitude, longitude)
``` ```
#### 参数说明 #### 参数说明
@ -609,13 +539,13 @@ window.plugins.jPushPlugin.prototype.setLocation(latitude, longitude)
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.isPlatformIOS() window.JPush.isPlatformIOS()
``` ```
#### 代码示例 #### 代码示例
```js ```js
if(window.plugins.jPushPlugin.isPlatformIOS()) { if(window.JPush.isPlatformIOS()) {
// iOS // iOS
} else { } else {
// Android // Android
@ -639,7 +569,7 @@ if(window.plugins.jPushPlugin.isPlatformIOS()) {
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.addDismissActions(actions, categoryId); window.JPush.addDismissActions(actions, categoryId);
``` ```
#### 参数说明 #### 参数说明
@ -660,7 +590,7 @@ window.plugins.jPushPlugin.addDismissActions(actions, categoryId);
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.addDismissActions([ window.JPush.addDismissActions([
{"title":"t1", "identifier":"id1", "option":"0"}, {"title":"t1", "identifier":"id1", "option":"0"},
{"title":"t2", "identifier":"id2", "option":"3", "type":"textInput", "textInputButtonTitle":"回复", "textInputPlaceholder":"点此输入回复内容"}], "categoryId_t1_t2"); {"title":"t2", "identifier":"id2", "option":"3", "type":"textInput", "textInputButtonTitle":"回复", "textInputPlaceholder":"点此输入回复内容"}], "categoryId_t1_t2");
``` ```
@ -680,7 +610,7 @@ iPhone 6s 及以后设备且 iOS 9 以后系统支持 3d-touch。
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.addNotificationActions(actions, categoryId) window.JPush.addNotificationActions(actions, categoryId)
``` ```
#### 参数说明 #### 参数说明
@ -742,7 +672,7 @@ window.plugins.jPushPlugin.addNotificationActions(actions, categoryId)
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.getUserNotificationSettings(callback) window.JPush.getUserNotificationSettings(callback)
``` ```
#### 返回值 #### 返回值