Merge branch 'dev'

This commit is contained in:
Hevin 2017-09-08 14:32:18 +08:00
commit 5c569d00da
4 changed files with 183 additions and 415 deletions

View File

@ -63,6 +63,10 @@
右键单击工程名 -> Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。 右键单击工程名 -> Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。
#### 无法获取到 Registration Id
检查 AppKey 和应用包名是否对应。
#### 如何自定义通知声音? #### 如何自定义通知声音?
Android 因为各 Rom 的高度定制化,不像 iOS 一样能有一个统一的管理,如果在 Android 中想自定义通知铃声,推荐通过 JPush 推送自定义 Android 因为各 Rom 的高度定制化,不像 iOS 一样能有一个统一的管理,如果在 Android 中想自定义通知铃声,推荐通过 JPush 推送自定义

View File

@ -1,135 +0,0 @@
#Android 手动安装
下载 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/
3. 复制:$JPUSH_PLUGIN_DIR/src/android/jpush-sdk-release2.0.6.jar 到 lib/
4. 复制:$JPUSH_PLUGIN_DIR/src/android/test_notification_layout.xml 到 res/layout/
5. 复制:$JPUSH_PLUGIN_DIR/src/android/jpush_notification_icon.png 到 res/drawable/
6. 复制:$JPUSH_PLUGIN_DIR/www/JPushPlugin.js 到 assets/www/plugins/cn.jpush.phonegap.JPushPlugin.www/
和 platform_www/plugins/cn.jpush.phonegap.JPushPlugin/www/
并在 JPushPlugin.js 文件的代码外添加:
cordova.define("cn.jpush.phonegap.JPushPlugin.JPushPlugin", function(require, exports, module) {
// 代码
});
7. 修改 AndroidManifest.xml 在 manifest 节点下添加以下权限
<!-- Required 一些系统要求的权限,如访问网络等-->
<uses-permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE"/>
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<permission
android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE"
android:protectionLevel="signature"/>
7. 修改 AndroidManifest.xml 在 manifest/application 节点下添加SDK相关组件声明
<activity
android:name="cn.jpush.android.ui.PushActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
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"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="cn.jpush.android.intent.REGISTER"/>
<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"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
<!-- User defined. For test only 用户自定义的广播接收器 -->
<receiver
android:name="cn.jpush.phonegap.MyReceiver"
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"/>
<!-- 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"/>

View File

@ -20,7 +20,6 @@
- [获取用户推送设置](#获取用户推送设置) - [获取用户推送设置](#获取用户推送设置)
- [监听事件统一说明](#监听事件统一说明) - [监听事件统一说明](#监听事件统一说明)
## 延迟注册和启动推送通知服务 ## 延迟注册和启动推送通知服务
本插件默认在 App 启动完成之后,立即「注册苹果通知服务」+「启动 JPush SDK」其中 本插件默认在 App 启动完成之后,立即「注册苹果通知服务」+「启动 JPush SDK」其中
@ -30,8 +29,8 @@
开发者可以根据自己的需求,延迟注册和启动,需做以下操作: 开发者可以根据自己的需求,延迟注册和启动,需做以下操作:
1. 查找并配置 `PushConfig.plist` 文件中的 `Delay` 字段为 `YES`,表明会延迟使用,此时插件不再自动注册、启动通知。 1.查找并配置 `PushConfig.plist` 文件中的 `Delay` 字段为 `YES`,表明会延迟使用,此时插件不再自动注册、启动通知。
2. 在需要注册并启动通知的地方调用 API - startJPushSDK。 2.在需要注册并启动通知的地方调用 API - `startJPushSDK`
### API - startJPushSDK ### API - startJPushSDK
@ -39,11 +38,10 @@
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.startJPushSDK() window.plugins.jPushPlugin.startJPushSDK()
``` ```
## 开始与停止推送服务 ## 开始与停止推送服务
### API - init ### API - init
@ -52,17 +50,15 @@ window.plugins.jPushPlugin.startJPushSDK()
开发者 App 可以通过调用停止推送服务 API 来停止极光推送服务,当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。 开发者 App 可以通过调用停止推送服务 API 来停止极光推送服务,当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。
```
本功能是一个完全本地的状态操作。也就是说:停止推送服务的状态不会保存到服务器上。 本功能是一个完全本地的状态操作。也就是说:停止推送服务的状态不会保存到服务器上。
如果停止推送服务后,开发者 App 被重新安装,或者被清除数据, 如果停止推送服务后,开发者 App 被重新安装,或者被清除数据,
JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数据被清除掉了)。 JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数据被清除掉了)。
本功能其行为类似于网络中断的效果,即:推送服务停止期间推送的消息, 本功能其行为类似于网络中断的效果,即:推送服务停止期间推送的消息,
恢复推送服务后,如果推送的消息还在保留的时长范围内,则客户端是会收到离线消息。 恢复推送服务后,如果推送的消息还在保留的时长范围内,则客户端是会收到离线消息。
```
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.init() window.plugins.jPushPlugin.init()
``` ```
@ -73,7 +69,9 @@ window.plugins.jPushPlugin.init()
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.stopPush() ```js
window.plugins.jPushPlugin.stopPush()
```
### API - resumePush ### API - resumePush
@ -81,7 +79,7 @@ window.plugins.jPushPlugin.init()
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.resumePush() window.plugins.jPushPlugin.resumePush()
``` ```
@ -91,7 +89,7 @@ iOS平台检查推送服务是否停止。
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.isPushStopped(callback) window.plugins.jPushPlugin.isPushStopped(callback)
``` ```
@ -103,12 +101,12 @@ window.plugins.jPushPlugin.isPushStopped(callback)
```js ```js
window.plugins.jPushPlugin.isPushStopped(function(data) { window.plugins.jPushPlugin.isPushStopped(function(data) {
if(data > 0) { if(data > 0) {
// 已关闭 // 已关闭
} else { } else {
// 已开启 // 已开启
} }
}) })
``` ```
## 获取 RegistrationID ## 获取 RegistrationID
@ -125,7 +123,7 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
#### 接口定义 #### 接口定义
```js ```js
JPushPlugin.prototype.getRegistrationID(callback) JPushPlugin.getRegistrationID(callback)
``` ```
#### 返回值 #### 返回值
@ -136,12 +134,10 @@ JPushPlugin.prototype.getRegistrationID(callback)
```js ```js
window.plugins.jPushPlugin.getRegistrationID(function(data) { window.plugins.jPushPlugin.getRegistrationID(function(data) {
console.log("JPushPlugin:registrationID is " + data) console.log("JPushPlugin:registrationID is " + data)
}) })
``` ```
## 别名与标签 ## 别名与标签
### API - setTagsWithAlias, setTags, setAlias ### API - setTagsWithAlias, setTags, setAlias
@ -160,7 +156,7 @@ window.plugins.jPushPlugin.getRegistrationID(function(data) {
系统不限定一个别名只能指定一个用户。如果一个别名被指定到了多个用户,当给指定这个别名发消息时,服务器端 API 会同时给这多个用户发送消息。 系统不限定一个别名只能指定一个用户。如果一个别名被指定到了多个用户,当给指定这个别名发消息时,服务器端 API 会同时给这多个用户发送消息。
举例:在一个用户要登录的游戏中,可能设置别名为 userid。游戏运营时发现该用户 3 天没有玩游戏了,则根据 userid 调用服务器端 API 发通知到客户端提醒用户。 举例:在一个用户要登录的游戏中,可能设置别名为 userId。游戏运营时发现该用户 3 天没有玩游戏了,则根据 userId 调用服务器端 API 发通知到客户端提醒用户。
**标签 Tag** **标签 Tag**
@ -174,10 +170,10 @@ window.plugins.jPushPlugin.getRegistrationID(function(data) {
#### 接口定义 #### 接口定义
``` ```js
JPushPlugin.prototype.setTagsWithAlias(tags, alias, successCallback, errorCallback) window.plugins.jPushPlugin.setTagsWithAlias(tags, alias, successCallback, errorCallback)
JPushPlugin.prototype.setTags(tags, successCallback) window.plugins.jPushPlugin.setTags(tags, successCallback)
JPushPlugin.prototype.setAlias(alias, errorCallback) window.plugins.jPushPlugin.setAlias(alias, errorCallback)
``` ```
#### 参数说明 #### 参数说明
@ -204,12 +200,12 @@ JPushPlugin.prototype.setAlias(alias, errorCallback)
| 6001 | 无效的设置tag/alias 不应参数都为 null | | | 6001 | 无效的设置tag/alias 不应参数都为 null | |
| 6002 | 设置超时 | 建议重试。 | | 6002 | 设置超时 | 建议重试。 |
| 6003 | alias 字符串不合法 | 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。 | | 6003 | alias 字符串不合法 | 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。 |
| 6004 | alias超长 | 最多 40个字节 中文 UTF-8 是 3 个字节。 | | 6004 | alias超长 | 最多 40 个字节(中文 UTF-8 是 3 个字节)。 |
| 6005 | 某一个 tag 字符串不合法 | 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。 | | 6005 | 某一个 tag 字符串不合法 | 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。 |
| 6006 | 某一个 tag 超长 | 一个 tag 最多 40个字节 中文 UTF-8 是 3 个字节。 | | 6006 | 某一个 tag 超长 | 一个 tag 最多 40 个字节(中文 UTF-8 是 3 个字节)。 |
| 6007 | tags 数量超出限制(最多 100 个) | 这是一台设备的限制。一个应用全局的标签数量无限制。 | | 6007 | tags 数量超出限制(最多 100 个) | 这是一台设备的限制。一个应用全局的标签数量无限制。 |
| 6008 | tag/alias 超出总长度限制 | 总长度最多 1K 字节。 | | 6008 | tag/alias 超出总长度限制 | 总长度最多 1K 字节。 |
| 6011 | 10s内设置tag或alias大于3次 | 短时间内操作过于频繁。 | | 6011 | 10 秒内设置 tag 或 alias 大于 3 次 | 短时间内操作过于频繁。 |
## 获取 APNS 推送内容 ## 获取 APNS 推送内容
@ -223,34 +219,33 @@ JPushPlugin.prototype.setAlias(alias, errorCallback)
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js ```js
document.addEventListener("jpush.openNotification", onOpenNotification, false) document.addEventListener("jpush.openNotification", onOpenNotification, false)
``` ```
- onOpenNotification 需要这样写: - onOpenNotification 需要这样写:
```js ```js
var onOpenNotification = function(event) { var onOpenNotification = function(event) {
var alertContent var alertContent = event.aps.alert
alertContent = event.aps.alert alert("open notification:" + alertContent)
alert("open Notificaiton:" + alertContent) }
} ```
```
- event 举例: - event 举例:
```json ```json
{ {
"aps":{ "aps":{
"badge":1, "badge":1,
"sound":"default", "sound":"default",
"alert":"今天去哪儿" "alert":"今天去哪儿"
}, },
"key1":"value1", "key1":"value1",
"key2":"value2", "key2":"value2",
"_j_msgid":154604475 "_j_msgid":154604475
} }
``` ```
### 前台收到推送 ### 前台收到推送
@ -262,34 +257,33 @@ JPushPlugin.prototype.setAlias(alias, errorCallback)
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js ```js
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false) document.addEventListener("jpush.receiveNotification", onReceiveNotification, false)
``` ```
- onReceiveNotification 需要这样写: - onReceiveNotification 需要这样写:
```js ```js
var onReceiveNotification = function(event) { var onReceiveNotification = function(event) {
var alertContent var alertContent = event.aps.alert
alertContent = event.aps.alert alert("open Notification:" + alertContent)
alert("open Notificaiton:" + alertContent) }
} ```
```
- event 举例 - event 举例
```json ```json
{ {
"aps":{ "aps":{
"badge":1, "badge":1,
"sound":"default", "sound":"default",
"alert":"今天去哪儿" "alert":"今天去哪儿"
}, },
"key1":"value1", "key1":"value1",
"key2":"value2", "key2":"value2",
"_j_msgid":154604475 "_j_msgid":154604475
} }
``` ```
### 后台收到推送 ### 后台收到推送
@ -301,100 +295,92 @@ JPushPlugin.prototype.setAlias(alias, errorCallback)
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js ```js
document.addEventListener("jpush.backgroundNotification", onBackgroundNotification, false) document.addEventListener("jpush.backgroundNotification", onBackgroundNotification, false)
``` ```
- onBackgroundNotification 需要这样写: - onBackgroundNotification 需要这样写:
```js ```js
var onBackgroundNotification = function(event) { var onBackgroundNotification = function(event) {
var alertContent var alertContent = event.aps.alert
alertContent = event.aps.alert alert("open Notification:" + alertContent)
alert("open Notificaiton:" + alertContent) }
} ```
```
- event 举例 - event 举例
```json ```json
{ {
"aps":{ "aps":{
"badge":1, "badge":1,
"sound":"default", "sound":"default",
"alert":"今天去哪儿" "alert":"今天去哪儿"
}, },
"key1":"value1", "key1":"value1",
"key2":"value2", "key2":"value2",
"_j_msgid":154604475 "_j_msgid":154604475
} }
``` ```
## 获取自定义消息内容
### event - jpush.receiveMessage ### event - jpush.receiveMessage
收到应用内消息时触发这个事件, 推荐使用事件的方式传递,但同时保留了 receiveMessageIniOSCallback 的回调函数,兼容以前的代码。 收到应用内消息时触发这个事件, 推荐使用事件的方式传递,但同时保留了 `receiveMessageIniOSCallback` 的回调函数,兼容以前的代码。
#### 代码示例 #### 代码示例
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js ```js
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false) document.addEventListener("jpush.receiveMessage", onReceiveMessage, false)
``` ```
- onReceiveMessage 需要这样写: - onReceiveMessage 需要这样写:
```js ```js
var onReceiveMessage = function(event) { var onReceiveMessage = function(event) {
try { try {
var message = event.content var message = event.content
$("#messageResult").html(message) $("#messageResult").html(message)
} catch(exception) { } catch(exception) {
console.log("JPushPlugin:onReceiveMessage-->" + exception); console.log("JPushPlugin:onReceiveMessage-->" + exception);
}
} }
``` }
```
- event 举例: - event 举例:
```json ```json
{
"content":"今天去哪儿",
"extras":
{ {
"content":"今天去哪儿", "key":"不填写没有"
"extras":
{
"key":"不填写没有"
}
} }
``` }
```
## 设置Badge ## 设置Badge
### API - setBadge, resetBadge ### API - setBadge, resetBadge
JPush 封装 badge 功能,允许应用上传 badge 值至 JPush 服务器,由 JPush 后台帮助管理每个用户所对应的推送 badge 值,简化了设置推送 badge 的操作。 JPush 封装 badge 功能,允许应用上传 badge 值至 JPush 服务器,由 JPush 后台帮助管理每个用户所对应的推送 badge 值,简化了设置推送 badge 的操作。
(本接口不会直接改变应用本地的角标值. 要修改本地 badege 值,使用 setApplicationIconBadgeNumber (本接口不会直接改变应用本地的角标值. 要修改本地 badge 值,使用 `setApplicationIconBadgeNumber`
实际应用中,开发者可以直接对 badge 值做增减操作,无需自己维护用户与 badge 值之间的对应关系。 实际应用中,开发者可以直接对 badge 值做增减操作,无需自己维护用户与 badge 值之间的对应关系。
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.prototype.setBadge(value) window.plugins.jPushPlugin.setBadge(value)
window.plugins.jPushPlugin.prototype.resetBadge() window.plugins.jPushPlugin.resetBadge()
``` ```
resetBadge 相当于 setBadge(0)。 `resetBadge` 相当于 `setBadge(0)`
#### 参数说明 #### 参数说明
value 取值范围:[0,99999] value 取值范围:0 ~ 99999
#### 返回值 #### 返回值
@ -414,16 +400,16 @@ window.plugins.jPushPlugin.resetBadge()
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.prototype.setApplicationIconBadgeNumber(badge) window.plugins.jPushPlugin.setApplicationIconBadgeNumber(badge)
``` ```
#### 参数说明 #### 参数说明
- badge: 整型,例如 012当 badge 为 0 时,角标被清除)。 - badge: 整型,例如 0, 1, 2当 badge 为 0 时,角标被清除)。
#### 代码示例 #### 代码示例
``` ```js
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0) window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0)
``` ```
@ -433,8 +419,8 @@ window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0)
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.getApplicationIconBadgeNumber(callback) window.plugins.jPushPlugin.getApplicationIconBadgeNumber(callback)
``` ```
#### 参数说明 #### 参数说明
@ -444,8 +430,8 @@ window.plugins.jPushPlugin.prototype.getApplicationIconBadgeNumber(callback)
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(data) { window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(badgeNum) {
console.log(data) console.log(badgeNum)
}) })
``` ```
@ -458,7 +444,7 @@ window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(data) {
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.prototype.addLocalNotificationForIOS(delayTime, content, badge, notificationID, extras) window.plugins.jPushPlugin.addLocalNotificationForIOS(delayTime, content, badge, notificationID, extras)
``` ```
#### 参数说明 #### 参数说明
@ -482,7 +468,7 @@ window.plugins.jPushPlugin.addLocalNotificationForIOS(24*60*60, "本地推送内
#### 接口定义 #### 接口定义
```js ```js
window.plugins.jPushPlugin.prototype.deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey) window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey)
``` ```
#### 参数说明 #### 参数说明
@ -491,7 +477,7 @@ window.plugins.jPushPlugin.prototype.deleteLocalNotificationWithIdentifierKeyInI
#### 代码示例 #### 代码示例
``` ```js
window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS("identifier") window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS("identifier")
``` ```
@ -501,38 +487,30 @@ window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS("identi
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.clearAllLocalNotifications() window.plugins.jPushPlugin.clearAllLocalNotifications()
``` ```
#### 代码示例 #### 代码示例
``` ```js
window.plugins.jPushPlugin.clearAllLocalNotifications() window.plugins.jPushPlugin.clearAllLocalNotifications()
``` ```
## 获取本地通知内容 ## 获取本地通知内容
### iOS 10 before 收到本地通知 ### iOS 10 before 收到本地通知
监听 `jpush.receiveLocalNotification` 事件获取「App 在后台时点击通知横幅」或「App 在前台时收到」均会触发该事件。 监听 `jpush.receiveLocalNotification` 事件获取「App 在后台时点击通知横幅」或「App 在前台时收到」均会触发该事件。
### iOS 10 收到本地通知 ### iOS 10 收到本地通知
监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。 监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。
### 点击本地通知横幅启动 App ### 点击本地通知横幅启动 App
监听 `jpush.startLocalNotification` 事件。 监听 `jpush.startLocalNotification` 事件。
## 页面的统计 ## 页面的统计
### API - startLogPageView, stopLogPageView, beginLogPageView ### API - startLogPageView, stopLogPageView, beginLogPageView
@ -542,16 +520,16 @@ window.plugins.jPushPlugin.clearAllLocalNotifications()
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.startLogPageView(pageName) window.plugins.jPushPlugin.startLogPageView(pageName)
window.plugins.jPushPlugin.prototype.stopLogPageView(pageName) window.plugins.jPushPlugin.stopLogPageView(pageName)
window.plugins.jPushPlugin.prototype.beginLogPageView(pageName, duration) window.plugins.jPushPlugin.beginLogPageView(pageName, duration)
``` ```
#### 参数说明 #### 参数说明
- pageName: 需要统计页面自定义名称 - pageName: 需要统计页面自定义名称
- duration: 自定义的页面时间 - duration: 自定义的页面时间
#### 调用说明 #### 调用说明
@ -561,7 +539,7 @@ window.plugins.jPushPlugin.prototype.beginLogPageView(pageName, duration)
#### 代码示例 #### 代码示例
``` ```js
window.plugins.jPushPlugin.beginLogPageView("newPage", 5); window.plugins.jPushPlugin.beginLogPageView("newPage", 5);
window.plugins.jPushPlugin.startLogPageView("onePage"); window.plugins.jPushPlugin.startLogPageView("onePage");
window.plugins.jPushPlugin.stopLogPageView("onePage"); window.plugins.jPushPlugin.stopLogPageView("onePage");
@ -573,17 +551,11 @@ window.plugins.jPushPlugin.stopLogPageView("onePage");
用于开启 Debug 模式,显示更多的日志信息。 用于开启 Debug 模式,显示更多的日志信息。
建议调试时开启这个选项,不调试的时候注释这句代码,这个函数 setLogOFF 是相反的一对。 建议调试时开启这个选项,不调试的时候注释这句代码,这个函数 `setLogOFF` 是相反的一对。
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.setDebugModeFromIos()
```
#### 代码示例
```
window.plugins.jPushPlugin.setDebugModeFromIos(); window.plugins.jPushPlugin.setDebugModeFromIos();
``` ```
@ -595,13 +567,7 @@ window.plugins.jPushPlugin.setDebugModeFromIos();
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.setLogOFF()
```
#### 代码示例
```
window.plugins.jPushPlugin.setLogOFF(); window.plugins.jPushPlugin.setLogOFF();
``` ```
@ -613,13 +579,7 @@ window.plugins.jPushPlugin.setLogOFF();
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.setCrashLogON()
```
#### 代码示例
```
window.plugins.jPushPlugin.setCrashLogON(); window.plugins.jPushPlugin.setCrashLogON();
``` ```
@ -631,7 +591,7 @@ window.plugins.jPushPlugin.setCrashLogON();
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.setLocation(latitude, longitude) window.plugins.jPushPlugin.prototype.setLocation(latitude, longitude)
``` ```
@ -640,12 +600,6 @@ window.plugins.jPushPlugin.prototype.setLocation(latitude, longitude)
- latitude: 地理位置纬度,数值类型或纯数字的字符型均可。 - latitude: 地理位置纬度,数值类型或纯数字的字符型均可。
- longitude: 地理位置精度,数值类型或纯数字的字符型均可。 - longitude: 地理位置精度,数值类型或纯数字的字符型均可。
#### 代码示例
```
window.plugins.jPushPlugin.setLocation(39.26,115.25);
```
## 设备平台判断 ## 设备平台判断
### API - isPlatformIOS ### API - isPlatformIOS
@ -654,22 +608,20 @@ window.plugins.jPushPlugin.setLocation(39.26,115.25);
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.isPlatformIOS() window.plugins.jPushPlugin.isPlatformIOS()
``` ```
#### 代码示例 #### 代码示例
```js ```js
if(window.plugins.jPushPlugin.isPlatformIOS()) { if(window.plugins.jPushPlugin.isPlatformIOS()) {
// iOS // iOS
} else { } else {
// Android // Android
} }
``` ```
## iOS 10 进阶推送特性 ## iOS 10 进阶推送特性
### API - addDismissActions ### API - addDismissActions
@ -686,8 +638,8 @@ if(window.plugins.jPushPlugin.isPlatformIOS()) {
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.addDismissActions(actions, categoryId); window.plugins.jPushPlugin.addDismissActions(actions, categoryId);
``` ```
#### 参数说明 #### 参数说明
@ -708,7 +660,9 @@ window.plugins.jPushPlugin.prototype.addDismissActions(actions, categoryId);
#### 代码示例 #### 代码示例
```js ```js
window.plugins.jPushPlugin.addDismissActions([{"title":"t1", "identifier":"id1", "option":"0"}, {"title":"t2", "identifier":"id2", "option":"3", "type":"textInput", "textInputButtonTitle":"回复", "textInputPlaceholder":"点此输入回复内容"}], "categoryId_t1_t2"); window.plugins.jPushPlugin.addDismissActions([
{"title":"t1", "identifier":"id1", "option":"0"},
{"title":"t2", "identifier":"id2", "option":"3", "type":"textInput", "textInputButtonTitle":"回复", "textInputPlaceholder":"点此输入回复内容"}], "categoryId_t1_t2");
``` ```
### API - addNotificationActions ### API - addNotificationActions
@ -725,8 +679,8 @@ iPhone 6s 及以后设备且 iOS 9 以后系统支持 3d-touch。
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.addNotificationActions(actions, categoryId) window.plugins.jPushPlugin.addNotificationActions(actions, categoryId)
``` ```
#### 参数说明 #### 参数说明
@ -745,23 +699,23 @@ window.plugins.jPushPlugin.prototype.addNotificationActions(actions, categoryId)
#### 配置方法 #### 配置方法
1. 首先配置好 iOS 项目的证书。如下图所示没有任何异常警告: 1.首先配置好 iOS 项目的证书。如下图所示没有任何异常警告:
![](res/MediaAttachments_01.png) ![](res/MediaAttachments_01.png)
2. 打开 iOS Xcode Project - File - New - Target - iOS - Notification Service Extension - Next - Product Name 填写 `jpushNotificationService` - Finish如下图所示 ![](res/MediaAttachments_02.png) 2.打开 iOS Xcode Project - File - New - Target - iOS - Notification Service Extension - Next - Product Name 填写 `jpushNotificationService` - Finish如下图所示 ![](res/MediaAttachments_02.png)
![MediaAttachments_03](res/MediaAttachments_03.png) ![MediaAttachments_03](res/MediaAttachments_03.png)
![MediaAttachments_04](res/MediaAttachments_04.png) ![MediaAttachments_04](res/MediaAttachments_04.png)
3. 在 Xcode 工程目录左侧系统自动创建了 jpushNotificationService 文件夹及三个文件,下载本插件目录 `jpush-phonegap-plugin/src/ios/notificationService/` 下的 `NotificationService.h`、`NotificationService.m` 文件,全部复制替换对应文件内代码。 3.在 Xcode 工程目录左侧系统自动创建了 jpushNotificationService 文件夹及三个文件,下载本插件目录 `jpush-phonegap-plugin/src/ios/notificationService/` 下的 `NotificationService.h`、`NotificationService.m` 文件,全部复制替换对应文件内代码。
4. 在 Xcode 中拖拽图片、gif、audio、video 等资源文件至 `jpushNotificationService` 文件夹目录下,弹出菜单选择如下: ![MediaAttachments_06](res/MediaAttachments_06.png) 4.在 Xcode 中拖拽图片、gif、audio、video 等资源文件至 `jpushNotificationService` 文件夹目录下,弹出菜单选择如下: ![MediaAttachments_06](res/MediaAttachments_06.png)
5. 在极光控制台 - 发送通知 - 可选设置 - mutable-content 打勾。 5.在极光控制台 - 发送通知 - 可选设置 - mutable-content 打勾。
6. 添加附加字段, key 为 `JPushPluginAttachment` value 为资源名称如 `aPic.png`,该资源必须在第 4 步中已经添加至工程且文件名和拓展名完全对应。5、6 如下图所示: 6.添加附加字段, key 为 `JPushPluginAttachment` value 为资源名称如 `aPic.png`,该资源必须在第 4 步中已经添加至工程且文件名和拓展名完全对应。5、6 如下图所示:
![MediaAttachments_05](res/MediaAttachments_05.png) ![MediaAttachments_05](res/MediaAttachments_05.png)
@ -769,15 +723,15 @@ window.plugins.jPushPlugin.prototype.addNotificationActions(actions, categoryId)
```json ```json
{ {
aps:{ aps:{
alert:{...}, alert:{...},
mutable-content:1 //必须 mutable-content:1 //必须
} }
JPushPluginAttachment:aPic.png //必须 JPushPluginAttachment:aPic.png //必须
} }
``` ```
7. 立即发送。 7.立即发送。
## 获取用户推送设置 ## 获取用户推送设置
@ -787,8 +741,8 @@ window.plugins.jPushPlugin.prototype.addNotificationActions(actions, categoryId)
#### 接口定义 #### 接口定义
``` ```js
window.plugins.jPushPlugin.prototype.getUserNotificationSettings(callback) window.plugins.jPushPlugin.getUserNotificationSettings(callback)
``` ```
#### 返回值 #### 返回值
@ -814,52 +768,38 @@ window.plugins.jPushPlugin.prototype.getUserNotificationSettings(callback)
- UNAlertStyleAlert = 2 - UNAlertStyleAlert = 2
## 监听事件统一说明 ## 监听事件统一说明
可在 js 监听全部事件如下: 可在 js 监听全部事件如下:
##### jpush.receiveNotification ### jpush.receiveNotification
> [前台收到远程通知](#前台收到推送) [前台收到远程通知](#前台收到推送)
>
> [iOS 10 前台收到本地通知](#ios-10-收到本地通知)
[iOS 10 前台收到本地通知](#ios-10-收到本地通知)
### jpush.openNotification
##### jpush.openNotification [点击远程通知横幅使 App「进入前台」或「启动」](#点击推送通知)
> [点击远程通知横幅使 App「进入前台」或「启动」](#点击推送通知) [iOS 10 点击本地通知横幅使 App「进入前台」或「启动」](#ios-10-收到本地通知)
>
> [iOS 10 点击本地通知横幅使 App「进入前台」或「启动」](#ios-10-收到本地通知)
### jpush.backgroundNotification
[iOS 7 以后后台收到远程通知](#后台收到推送)
##### jpush.backgroundNotification ### jpush.setTagsWithAlias
> [iOS 7 以后后台收到远程通知](#后台收到推送) [设置标签别名回调](#返回值说明)
### jpush.receiveMessage
[获取自定义消息内容](#获取自定义消息内容)
##### jpush.setTagsWithAlias ### jpush.startLocalNotification
> [设置标签别名回调](#返回值说明) [点击本地通知横幅启动 App](#点击本地通知横幅启动-app)
### jpush.receiveLocalNotification
[iOS 10 before 收到本地通知](#ios-10-before-收到本地通知)
##### jpush.receiveMessage
> [获取自定义消息内容](#获取自定义消息内容)
##### jpush.startLocalNotification
> [点击本地通知横幅启动 App](#点击本地通知横幅启动-app)
##### jpush.receiveLocalNotification
> [iOS 10 before 收到本地通知](#ios-10-before-收到本地通知)

View File

@ -1,41 +0,0 @@
## iOS 手动安装
> **不建议使用手动安装,请参照 README.md 进行自动安装。**
1. 下载 JPush PhoneGap Plugin 插件,并解压
2. 将 [/src/ios](/src/ios) 文件夹及内容在 xcode 中拖到你的工程里,并配置 [/src/ios/PushConfig.plist](/src/ios/PushConfig.plist) 中相应参数:
Appkey 应用标识
Channel 渠道标识
IsProduction是否生产环境
IsIDFA 是否使用 IDFA 启动 sdk
3. 打开 xcode点击工程目录中顶部的 工程,选择(Target -> Build Phases -> Link Binary With Libraries),添加以下框架:
CFNetwork.framework
CoreFoundation.framework
CoreTelephony.framework
SystemConfiguration.framework
CoreGraphics.framework
Foundation.framework
UIKit.framework
AdSupport.framework
libz.tbd(若存在 libz.dylib 则替换为 libz.tbd)
UserNotifications.framework
libresolv.tbd
4. 修改 phonegap config.xml 文件以添加 JPushPlugin 插件
```xml
<feature name="JPushPlugin">
<param name="ios-package" value="JPushPlugin" />
<param name="onload" value="true" />
</feature>
```
5. 将 [/www/JPushPlugin.js](/www/JPushPlugin.js) 在 xcode 中拖到工程的 www 目录下面
6. 在需要使用插件处加入以下代码,并根据 [iOS API](/doc/iOS_API.md) 文档说明调用相应接口
```xml
<script type="text/javascript" src="JPushPlugin.js"></script>
```