iOS - update

1.增加本地通知事件
2.更新 doc
3.fix bug
This commit is contained in:
pikacode 2016-12-06 13:56:27 +08:00
parent 7ca29c3397
commit 309131e944
6 changed files with 335 additions and 164 deletions

View File

@ -10,12 +10,14 @@
- [获取自定义消息内容](#获取自定义消息内容) - [获取自定义消息内容](#获取自定义消息内容)
- [设置Badge](#设置badge) - [设置Badge](#设置badge)
- [本地通知](#本地通知) - [本地通知](#本地通知)
- [获取本地通知内容](#获取本地通知内容)
- [页面的统计](#页面的统计) - [页面的统计](#页面的统计)
- [日志等级设置](#日志等级设置) - [日志等级设置](#日志等级设置)
- [地理位置上报](#地理位置上报) - [地理位置上报](#地理位置上报)
- [设备平台判断](#设备平台判断) - [设备平台判断](#设备平台判断)
- [iOS 10 进阶推送特性](#ios-10-进阶推送特性) - [iOS 10 进阶推送特性](#ios-10-进阶推送特性)
- [获取用户推送设置](#获取用户推送设置) - [获取用户推送设置](#获取用户推送设置)
- [监听事件统一说明](#监听事件统一说明)
## 开始与停止推送服务 ## 开始与停止推送服务
@ -35,7 +37,9 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.init() ```
window.plugins.jPushPlugin.init()
```
### API - stopPush ### API - stopPush
@ -52,7 +56,10 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.resumePush() ```
window.plugins.jPushPlugin.resumePush()
```
### API - isPushStopped ### API - isPushStopped
@ -61,7 +68,9 @@ iOS平台检查推送服务是否停止。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.isPushStopped(callback) ```
window.plugins.jPushPlugin.isPushStopped(callback)
```
#### 参数说明 #### 参数说明
@ -69,13 +78,15 @@ iOS平台检查推送服务是否停止。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.isPushStopped(function(data) { ```js
window.plugins.jPushPlugin.isPushStopped(function(data) {
if(data > 0) { if(data > 0) {
// 已关闭 // 已关闭
} else { } else {
// 已开启 // 已开启
} }
}) })
```
## 获取 RegistrationID ## 获取 RegistrationID
@ -90,7 +101,9 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
#### 接口定义 #### 接口定义
JPushPlugin.prototype.getRegistrationID(callback) ```js
JPushPlugin.prototype.getRegistrationID(callback)
```
#### 返回值 #### 返回值
@ -98,9 +111,13 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
#### 调用示例 #### 调用示例
window.plugins.jPushPlugin.getRegistrationID(function(data) { ```js
window.plugins.jPushPlugin.getRegistrationID(function(data) {
console.log("JPushPlugin:registrationID is " + data) console.log("JPushPlugin:registrationID is " + data)
}) })
```
## 别名与标签 ## 别名与标签
@ -134,38 +151,43 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
#### 接口定义 #### 接口定义
JPushPlugin.prototype.setTagsWithAlias(tags, alias) ```
JPushPlugin.prototype.setTags(tags) JPushPlugin.prototype.setTagsWithAlias(tags, alias)
JPushPlugin.prototype.setAlias(alias) JPushPlugin.prototype.setTags(tags)
JPushPlugin.prototype.setAlias(alias)
```
#### 参数说明 #### 参数说明
* tags:
* 参数类型为数组。 - tags:
* nil 此次调用不设置此值。 - 参数类型为数组。
* 空集合表示取消之前的设置。 - nil 此次调用不设置此值。
* 每次调用至少设置一个 tag覆盖之前的设置不是新增。 - 空集合表示取消之前的设置。
* 有效的标签组成:字母(区分大小写)、数字、下划线、汉字。 - 每次调用至少设置一个 tag覆盖之前的设置不是新增。
* 限制:每个 tag 命名长度限制为 40 字节,最多支持设置 100 个 tag但总长度不得超过1K字节判断长度需采用UTF-8编码 - 有效的标签组成:字母(区分大小写)、数字、下划线、汉字。
* 单个设备最多支持设置 100 个 tagApp 全局 tag 数量无限制。 - 限制:每个 tag 命名长度限制为 40 字节,最多支持设置 100 个 tag但总长度不得超过1K字节判断长度需采用UTF-8编码
* alias: - 单个设备最多支持设置 100 个 tagApp 全局 tag 数量无限制。
* 参数类型为字符串。 - alias:
* nil 此次调用不设置此值。 - 参数类型为字符串。
* 空字符串 "")表示取消之前的设置。 - nil 此次调用不设置此值。
* 有效的别名组成:字母(区分大小写)、数字、下划线、汉字。 - 空字符串 "")表示取消之前的设置。
* 限制alias 命名长度限制为 40 字节(判断长度需采用 UTF-8 编码)。 - 有效的别名组成:字母(区分大小写)、数字、下划线、汉字。
- 限制alias 命名长度限制为 40 字节(判断长度需采用 UTF-8 编码)。
#### 返回值说明 #### 返回值说明
函数本身无返回值,但需要注册 `jpush.setTagsWithAlias` 事件来监听设置结果。 函数本身无返回值,但需要注册 `jpush.setTagsWithAlias` 事件来监听设置结果。
var onTagsWithAlias = function(event) { ```js
var onTagsWithAlias = function(event) {
console.log("onTagsWithAlias") console.log("onTagsWithAlias")
var result = "result code:"+event.resultCode + " " var result = "result code:"+event.resultCode + " "
result += "tags:" + event.tags + " " result += "tags:" + event.tags + " "
result += "alias:" + event.alias + " " result += "alias:" + event.alias + " "
$("#tagAliasResult").html(result) $("#tagAliasResult").html(result)
} }
document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false) document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false)
```
#### 错误码定义 #### 错误码定义
@ -181,7 +203,6 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
| 6008 | tag/alias 超出总长度限制 | 总长度最多 1K 字节。 | | 6008 | tag/alias 超出总长度限制 | 总长度最多 1K 字节。 |
| 6011 | 10s内设置tag或alias大于3次 | 短时间内操作过于频繁。 | | 6011 | 10s内设置tag或alias大于3次 | 短时间内操作过于频繁。 |
## 获取 APNS 推送内容 ## 获取 APNS 推送内容
### 点击推送通知 ### 点击推送通知
@ -194,18 +215,23 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js
document.addEventListener("jpush.openNotification", onOpenNotification, false) document.addEventListener("jpush.openNotification", onOpenNotification, false)
```
- onOpenNotification 需要这样写: - onOpenNotification 需要这样写:
```js
var onOpenNotification = function(event) { var onOpenNotification = function(event) {
var alertContent var alertContent
alertContent = event.aps.alert alertContent = event.aps.alert
alert("open Notificaiton:" + alertContent) alert("open Notificaiton:" + alertContent)
} }
```
- event 举例: - event 举例:
```json
{ {
"aps":{ "aps":{
"badge":1, "badge":1,
@ -216,6 +242,7 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
"key2":"value2", "key2":"value2",
"_j_msgid":154604475 "_j_msgid":154604475
} }
```
### 前台收到推送 ### 前台收到推送
@ -227,18 +254,23 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false) document.addEventListener("jpush.receiveNotification", onReceiveNotification, false)
```
- onReceiveNotification 需要这样写: - onReceiveNotification 需要这样写:
```js
var onReceiveNotification = function(event) { var onReceiveNotification = function(event) {
var alertContent var alertContent
alertContent = event.aps.alert alertContent = event.aps.alert
alert("open Notificaiton:" + alertContent) alert("open Notificaiton:" + alertContent)
} }
```
- event 举例 - event 举例
```json
{ {
"aps":{ "aps":{
"badge":1, "badge":1,
@ -249,6 +281,7 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
"key2":"value2", "key2":"value2",
"_j_msgid":154604475 "_j_msgid":154604475
} }
```
### 后台收到推送 ### 后台收到推送
@ -260,18 +293,24 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js
document.addEventListener("jpush.backgroundNotification", onBackgroundNotification, false) document.addEventListener("jpush.backgroundNotification", onBackgroundNotification, false)
```
- onBackgroundNotification 需要这样写: - onBackgroundNotification 需要这样写:
```js
var onBackgroundNotification = function(event) { var onBackgroundNotification = function(event) {
var alertContent var alertContent
alertContent = event.aps.alert alertContent = event.aps.alert
alert("open Notificaiton:" + alertContent) alert("open Notificaiton:" + alertContent)
} }
```
+ event 举例
- event 举例
```json
{ {
"aps":{ "aps":{
"badge":1, "badge":1,
@ -282,6 +321,11 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
"key2":"value2", "key2":"value2",
"_j_msgid":154604475 "_j_msgid":154604475
} }
```
## 获取自定义消息内容 ## 获取自定义消息内容
@ -293,10 +337,13 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
- 在你需要接收通知的的 js 文件中加入: - 在你需要接收通知的的 js 文件中加入:
```js
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false) document.addEventListener("jpush.receiveMessage", onReceiveMessage, false)
```
- onReceiveMessage 需要这样写: - onReceiveMessage 需要这样写:
```js
var onReceiveMessage = function(event) { var onReceiveMessage = function(event) {
try { try {
var message = event.content var message = event.content
@ -305,9 +352,11 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
console.log("JPushPlugin:onReceiveMessage-->" + exception); console.log("JPushPlugin:onReceiveMessage-->" + exception);
} }
} }
```
- event 举例: - event 举例:
```json
{ {
"content":"今天去哪儿", "content":"今天去哪儿",
"extras": "extras":
@ -315,31 +364,40 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
"key":"不填写没有" "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 (本接口不会直接改变应用本地的角标值. 要修改本地 badege 值,使用 setApplicationIconBadgeNumber
实际应用中,开发者可以直接对 badge 值做增减操作,无需自己维护用户与 badge 值之间的对应关系。 实际应用中,开发者可以直接对 badge 值做增减操作,无需自己维护用户与 badge 值之间的对应关系。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.setBadge(value) ```js
window.plugins.jPushPlugin.prototype.reSetBadge() window.plugins.jPushPlugin.prototype.setBadge(value)
window.plugins.jPushPlugin.prototype.reSetBadge()
```
resetBadge 相当于 setBadge(0)。 resetBadge 相当于 setBadge(0)。
#### 参数说明 #### 参数说明
value 取值范围:[0,99999]。 value 取值范围:[0,99999]。
#### 返回值 #### 返回值
无,控制台会有 log 打印设置结果。 无,控制台会有 log 打印设置结果。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.setBadge(5) ```js
window.plugins.jPushPlugin.reSetBadge() window.plugins.jPushPlugin.setBadge(5)
window.plugins.jPushPlugin.reSetBadge()
```
### API - setApplicationIconBadgeNumber ### API - setApplicationIconBadgeNumber
@ -347,7 +405,9 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.setApplicationIconBadgeNumber(badge) ```js
window.plugins.jPushPlugin.prototype.setApplicationIconBadgeNumber(badge)
```
#### 参数说明 #### 参数说明
@ -355,7 +415,9 @@ value 取值范围:[0,99999]。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0) ```
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0)
```
### API - getApplicationIconBadgeNumber ### API - getApplicationIconBadgeNumber
@ -363,7 +425,9 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.getApplicationIconBadgeNumber(callback) ```
window.plugins.jPushPlugin.prototype.getApplicationIconBadgeNumber(callback)
```
#### 参数说明 #### 参数说明
@ -371,10 +435,11 @@ value 取值范围:[0,99999]。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(data) { ```js
window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(data) {
console.log(data) console.log(data)
}) })
```
## 本地通知 ## 本地通知
@ -384,7 +449,9 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.addLocalNotificationForIOS(delayTime, content, badge, notificationID, extras) ```js
window.plugins.jPushPlugin.prototype.addLocalNotificationForIOS(delayTime, content, badge, notificationID, extras)
```
#### 参数说明 #### 参数说明
@ -396,7 +463,9 @@ value 取值范围:[0,99999]。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.addLocalNotificationForIOS(6*60*60, "本地推送内容", 1, "notiId", {"key":"value"}); ```js
window.plugins.jPushPlugin.addLocalNotificationForIOS(24*60*60, "本地推送内容", 1, "notiId", {"key":"value"});
```
### API - deleteLocalNotificationWithIdentifierKeyInIOS ### API - deleteLocalNotificationWithIdentifierKeyInIOS
@ -404,7 +473,9 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey) ```js
window.plugins.jPushPlugin.prototype.deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey)
```
#### 参数说明 #### 参数说明
@ -412,7 +483,9 @@ value 取值范围:[0,99999]。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS("identifier") ```
window.plugins.jPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS("identifier")
```
### API - clearAllLocalNotifications ### API - clearAllLocalNotifications
@ -420,11 +493,36 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.clearAllLocalNotifications() ```
window.plugins.jPushPlugin.prototype.clearAllLocalNotifications()
```
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.clearAllLocalNotifications() ```
window.plugins.jPushPlugin.clearAllLocalNotifications()
```
## 获取本地通知内容
### iOS 10 before 收到本地通知
监听 `jpush.receiveLocalNotification` 事件获取「App 在后台时点击通知横幅」或「App 在前台时收到」均会触发该事件。
### iOS 10 收到本地通知
监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。
### 点击本地通知横幅启动 App
监听 `jpush.startLocalNotification` 事件。
## 页面的统计 ## 页面的统计
@ -436,9 +534,11 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.startLogPageView(pageName) ```
window.plugins.jPushPlugin.prototype.stopLogPageView(pageName) window.plugins.jPushPlugin.prototype.startLogPageView(pageName)
window.plugins.jPushPlugin.prototype.beginLogPageView(pageName, duration) window.plugins.jPushPlugin.prototype.stopLogPageView(pageName)
window.plugins.jPushPlugin.prototype.beginLogPageView(pageName, duration)
```
#### 参数说明 #### 参数说明
@ -446,16 +546,18 @@ value 取值范围:[0,99999]。
- duration: 自定义的页面时间 - duration: 自定义的页面时间
#### 调用说明 #### 调用说明
应在所有的需要统计得页面得 viewWillAppear 和 viewWillDisappear 加入 startLogPageView 和 stopLogPageView 来统计当前页面的停留时间。 应在所有的需要统计得页面得 viewWillAppear 和 viewWillDisappear 加入 startLogPageView 和 stopLogPageView 来统计当前页面的停留时间。
或者直接使用 beginLogPageView 来自定义加入页面和时间信息。 或者直接使用 beginLogPageView 来自定义加入页面和时间信息。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.beginLogPageView("newPage", 5); ```
window.plugins.jPushPlugin.startLogPageView("onePage"); window.plugins.jPushPlugin.beginLogPageView("newPage", 5);
window.plugins.jPushPlugin.stopLogPageView("onePage"); window.plugins.jPushPlugin.startLogPageView("onePage");
window.plugins.jPushPlugin.stopLogPageView("onePage");
```
## 日志等级设置 ## 日志等级设置
@ -467,11 +569,15 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.setDebugModeFromIos() ```
window.plugins.jPushPlugin.prototype.setDebugModeFromIos()
```
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.setDebugModeFromIos(); ```
window.plugins.jPushPlugin.setDebugModeFromIos();
```
### API - setLogOFF ### API - setLogOFF
@ -481,11 +587,15 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.setLogOFF() ```
window.plugins.jPushPlugin.prototype.setLogOFF()
```
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.setLogOFF(); ```
window.plugins.jPushPlugin.setLogOFF();
```
### API - setCrashLogON ### API - setCrashLogON
@ -495,11 +605,15 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.setCrashLogON() ```
window.plugins.jPushPlugin.prototype.setCrashLogON()
```
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.setCrashLogON(); ```
window.plugins.jPushPlugin.setCrashLogON();
```
## 地理位置上报 ## 地理位置上报
@ -509,7 +623,9 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.setLocation(latitude, longitude) ```
window.plugins.jPushPlugin.prototype.setLocation(latitude, longitude)
```
#### 参数说明 #### 参数说明
@ -518,7 +634,9 @@ value 取值范围:[0,99999]。
#### 代码示例 #### 代码示例
window.plugins.jPushPlugin.setLocation(39.26,115.25); ```
window.plugins.jPushPlugin.setLocation(39.26,115.25);
```
## 设备平台判断 ## 设备平台判断
@ -528,15 +646,19 @@ value 取值范围:[0,99999]。
#### 接口定义 #### 接口定义
window.plugins.jPushPlugin.prototype.isPlatformIOS() ```
window.plugins.jPushPlugin.prototype.isPlatformIOS()
```
#### 代码示例 #### 代码示例
if(window.plugins.jPushPlugin.isPlatformIOS()) { ```js
if(window.plugins.jPushPlugin.isPlatformIOS()) {
// iOS // iOS
} else { } else {
// Android // Android
} }
```
@ -577,7 +699,7 @@ window.plugins.jPushPlugin.prototype.addDismissActions(actions, categoryId);
#### 代码示例 #### 代码示例
``` ```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");
``` ```
@ -649,8 +771,6 @@ window.plugins.jPushPlugin.prototype.addNotificationActions(actions, categoryId)
7. 立即发送。 7. 立即发送。
## 获取用户推送设置 ## 获取用户推送设置
### API - getUserNotificationSettings ### API - getUserNotificationSettings
@ -684,3 +804,55 @@ window.plugins.jPushPlugin.prototype.getUserNotificationSettings(callback)
- UNAlertStyleNone = 0 - UNAlertStyleNone = 0
- UNAlertStyleBanner = 1 - UNAlertStyleBanner = 1
- UNAlertStyleAlert = 2 - UNAlertStyleAlert = 2
## 监听事件统一说明
可在 js 监听全部事件如下:
##### jpush.receiveNotification
> [前台收到远程通知](#前台收到推送)
>
> [iOS 10 前台收到本地通知](#ios-10-收到本地通知)
##### jpush.openNotification
> [点击远程通知横幅使 App「进入前台」或「启动」](#点击推送通知)
>
> [iOS 10 点击本地通知横幅使 App「进入前台」或「启动」](#ios-10-收到本地通知)
##### jpush.backgroundNotification
> [iOS 7 以后后台收到远程通知](#后台收到推送)
##### jpush.setTagsWithAlias
> [设置标签别名回调](#返回值说明)
##### jpush.receiveMessage
> [获取自定义消息内容](#获取自定义消息内容)
##### jpush.startLocalNotification
> [点击本地通知横幅启动 App](#点击本地通知横幅启动-app)
##### jpush.receiveLocalNotification
> [iOS 10 before 收到本地通知](#ios-10-before-收到本地通知)

View File

@ -2,7 +2,7 @@
// AppDelegate+JPush.h // AppDelegate+JPush.h
// delegateExtention // delegateExtention
// //
// Created by pikacode@qq.com on 15/8/3. // Created by 张庆贺 on 15/8/3.
// Copyright (c) 2015年 JPush. All rights reserved. // Copyright (c) 2015年 JPush. All rights reserved.
// //

View File

@ -2,7 +2,7 @@
// AppDelegate+JPush.m // AppDelegate+JPush.m
// delegateExtention // delegateExtention
// //
// Created by pikacode@qq.com on 15/8/3. // Created by on 15/8/3.
// Copyright (c) 2015 JPush. All rights reserved. // Copyright (c) 2015 JPush. All rights reserved.
// //
@ -28,8 +28,6 @@
return [self init_plus]; return [self init_plus];
} }
-(void)applicationDidLaunch:(NSNotification *)notification{ -(void)applicationDidLaunch:(NSNotification *)notification{
if (notification) { if (notification) {
if (notification.userInfo) { if (notification.userInfo) {
@ -39,7 +37,7 @@
} }
NSDictionary *userInfo2 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]; NSDictionary *userInfo2 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (userInfo2.count > 0) { if (userInfo2.count > 0) {
[SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_OpenLocalNotification jsString:[userInfo1 toJsonString]]; [SharedJPushPlugin jpushFireDocumentEvent:JPushDocumentEvent_StartLocalNotification jsString:[userInfo1 toJsonString]];
} }
} }
[JPUSHService setDebugMode]; [JPUSHService setDebugMode];
@ -91,7 +89,7 @@
eventName = JPushDocumentEvent_ReceiveNotification; eventName = JPushDocumentEvent_ReceiveNotification;
break; break;
case UIApplicationStateBackground: case UIApplicationStateBackground:
eventName = JPushDocumentEvent_BackgoundNotification; eventName = JPushDocumentEvent_BackgroundNotification;
break; break;
default: default:
break; break;
@ -117,7 +115,7 @@
} }
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
// [[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveLocalNotification object:notification.userInfo]; [[NSNotificationCenter defaultCenter] postNotificationName:JPushDocumentEvent_ReceiveLocalNotification object:notification.userInfo];
} }
- (void)applicationWillEnterForeground:(UIApplication *)application { - (void)applicationWillEnterForeground:(UIApplication *)application {

View File

@ -2,7 +2,7 @@
// ConstantDef.h // ConstantDef.h
// jmessage // jmessage
// //
// Created by pikacode@qq.com on 16/1/19. // Created by ljg on 16/1/19.
// //
// //
@ -23,9 +23,10 @@ static NSString *const JPushConfig_FileName = @"PushConfig";
static NSString *const JPushDocumentEvent_ReceiveNotification = @"receiveNotification"; static NSString *const JPushDocumentEvent_ReceiveNotification = @"receiveNotification";
static NSString *const JPushDocumentEvent_OpenNotification = @"openNotification"; static NSString *const JPushDocumentEvent_OpenNotification = @"openNotification";
static NSString *const JPushDocumentEvent_BackgoundNotification = @"backgoundNotification"; static NSString *const JPushDocumentEvent_BackgroundNotification = @"backgroundNotification";
static NSString *const JPushDocumentEvent_SetTagsWithAlias = @"setTagsWithAlias"; static NSString *const JPushDocumentEvent_SetTagsWithAlias = @"setTagsWithAlias";
static NSString *const JPushDocumentEvent_ReceiveMessage = @"receiveMessage"; static NSString *const JPushDocumentEvent_ReceiveMessage = @"receiveMessage";
static NSString *const JPushDocumentEvent_OpenLocalNotification = @"openLocalNotification"; static NSString *const JPushDocumentEvent_StartLocalNotification = @"startLocalNotification";
static NSString *const JPushDocumentEvent_ReceiveLocalNotification = @"receiveLocalNotification";

View File

@ -2,7 +2,7 @@
// PushTalkPlugin.h // PushTalkPlugin.h
// PushTalk // PushTalk
// //
// Created by pikacode@qq.com on 13-12-13. // Created by zhangqinghe on 13-12-13.
// //
// //

View File

@ -2,7 +2,7 @@
// PushTalkPlugin.m // PushTalkPlugin.m
// PushTalk // PushTalk
// //
// Created by pikacode@qq.com on 13-12-13. // Created by zhangqinghe on 13-12-13.
// //
// //
@ -164,7 +164,7 @@
NSNumber *badge = [command argumentAtIndex:2]; NSNumber *badge = [command argumentAtIndex:2];
NSString *idKey = [command argumentAtIndex:3]; NSString *idKey = [command argumentAtIndex:3];
NSDictionary *dict = [command argumentAtIndex:4]; NSDictionary *dict = [command argumentAtIndex:4];
[JPUSHService setLocalNotification:date alertBody:alert badge:badge alertAction:nil identifierKey:idKey userInfo:dict soundName:nil]; [JPUSHService setLocalNotification:date alertBody:alert badge:badge.intValue alertAction:nil identifierKey:idKey userInfo:dict soundName:nil];
} }
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command{ -(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command{
@ -266,7 +266,7 @@
NSNumber *isIDFA = [plistData valueForKey:JPushConfig_IsIDFA]; NSNumber *isIDFA = [plistData valueForKey:JPushConfig_IsIDFA];
NSString *advertisingId = nil; NSString *advertisingId = nil;
if(isIDFA){ if(isIDFA.boolValue){
advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]; advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
} }
[JPUSHService setupWithOption:userInfo [JPUSHService setupWithOption:userInfo