修改关于jpush.receiveNotification的文档,并删除旧有说明

This commit is contained in:
zhangqinghe 2015-06-09 17:31:57 +08:00
parent cb8f8412b4
commit 0233a10906
5 changed files with 75 additions and 41 deletions

View File

@ -140,9 +140,12 @@ l## JPush PhoneGap Plugin ##
window.plugins.jPushPlugin.setTagsWithAlias(tags,alias)
window.plugins.jPushPlugin.setTags(tags)
window.plugins.jPushPlugin.setAlias(alias)
+ 获取通知内容
+ 获取点击通知内容
event - jpush.openNotification
+ 获取通知内容
event - jpush.receiveNotification
+ 获取自定义消息推送内容
@ -152,9 +155,6 @@ l## JPush PhoneGap Plugin ##
[通用API详细说明](document/Common_detail_api.md)
#### iOS API简介
+ 获取 APNs通知 推送内容
event - jpush.receiveNotification
+ 获取自定义消息推送内容
@ -190,9 +190,8 @@ l## JPush PhoneGap Plugin ##
+ 获取集成日志
window.plugins.jPushPlugin.setDebugMode(mode)
+ 接收推送消息Receiver
+ 接收推送消息和点击通知
//推荐使用event jpush.Message和jpush.openNotification
//下面这两个api 是兼容旧有的代码
window.plugins.jPushPlugin.receiveMessageInAndroidCallback(data)
window.plugins.jPushPlugin.openNotificationInAndroidCallback(data)

View File

@ -20,7 +20,7 @@
- false 不显示集成日志
### 接收推送消息Receiver
### 接收消息和点击通知事件
#### API - receiveMessageInAndroidCallback
用于android收到应用内消息的回调函数(请注意和通知的区别),该函数不需要主动调用

View File

@ -219,7 +219,7 @@ android iOS
|6008| tag/alias 超出总长度限制。|总长度最多 1K 字节|
|6011| 10s内设置tag或alias大于3次| 短时间内操作过于频繁|
### 获取通知内容
### 获取点击通知内容
#### event - jpush.openNotification
@ -234,6 +234,54 @@ android iOS
- onOpenNotification需要这样写
var alertContent
if(device.platform == "Android"){
alertContent=window.plugins.jPushPlugin.openNotification.alert;
}else{
alertContent = event.aps.alert;
}
alert("open Notificaiton:"+alertContent);
ps点击通知后传递的json object 保存在window.plugins.jPushPlugin.openNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意
+ android
{"alert":"ding",
"extras":{
"cn.jpush.android.MSG_ID":"1691785879",
"app":"com.thi.pushtest",
"cn.jpush.android.ALERT":"ding",
"cn.jpush.android.EXTRA":{},
"cn.jpush.android.PUSH_ID":"1691785879",
"cn.jpush.android.NOTIFICATION_ID":1691785879,
"cn.jpush.android.NOTIFICATION_TYPE":"0"}}
+ iOS
{
"aps":{
"badge":1,
"sound":"default",
"alert":"今天去哪儿"
},
"_j_msgid":154604475
}
### 获取通知内容
#### event - jpush.receiveNotification
点击通知进入应用程序时会出发改事件
#####代码示例
- 在你需要接收通知的的js文件中加入:
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
- onReceiveNotification需要这样写
var alertContent
if(device.platform == "Android"){
alertContent=window.plugins.jPushPlugin.openNotification.alert;
@ -270,7 +318,6 @@ ps点击通知后传递的json object 保存在window.plugins.jPushPlugin.rec
### 获取自定义消息推送内容
### 获取自定义消息推送内容
####event - jpush.receiveMessage
@ -290,9 +337,12 @@ ps点击通知后传递的json object 保存在window.plugins.jPushPlugin.rec
var onReceiveMessage = function(event){
try{
var message = window.plugins.jPushPlugin.receiveMessage.message;
//var extras = window.plugins.jPushPlugin.extras
var message
if(device.platform == "Android"){
message = window.plugins.jPushPlugin.receiveMessage.message;
}else{
message = event.content;
}
$("#messageResult").html(message);
}

View File

@ -2,31 +2,6 @@
### 获取 APNs通知 推送内容
#### event - jpush.receiveNotification
当iOS收到的通知时会触发这个事件
#####代码示例
- 在你需要接收通知的的js文件中加入:
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
- onOpenNotification需要这样写
var onReceiveNotification = function(event){
try{
var alert = event.aps.alert;
console.log("JPushPlugin:onReceiveNotification key aps.alert:"+alert);
}
catch(exeption){
console.log(exception)
}
}
#### API - receiveMessageIniOSCallback

View File

@ -54,8 +54,12 @@
}
var onReceiveNotification = function(event){
try{
var alert = window.plugins.jPushPlugin.receiveNotification.alert;
var alert
if(device.platform == "Android"){
alert = window.plugins.jPushPlugin.receiveNotification.alert;
}else{
alert = event.aps.alert;
}
$("#notificationResult").html(alert);
}
@ -65,9 +69,15 @@
}
var onReceiveMessage = function(event){
try{
var message = window.plugins.jPushPlugin.receiveMessage.message;
var message
if(device.platform == "Android"){
message = window.plugins.jPushPlugin.receiveMessage.message;
}else{
message = event.content;
}
//var extras = window.plugins.jPushPlugin.extras
$("#messageResult").html(message);
}