mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-19 13:52:49 +08:00
修改关于jpush.receiveNotification的文档,并删除旧有说明
This commit is contained in:
parent
cb8f8412b4
commit
0233a10906
11
README.md
11
README.md
@ -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)
|
||||
|
@ -20,7 +20,7 @@
|
||||
- false 不显示集成日志
|
||||
|
||||
|
||||
### 接收推送消息Receiver
|
||||
### 接收消息和点击通知事件
|
||||
#### API - receiveMessageInAndroidCallback
|
||||
|
||||
用于android收到应用内消息的回调函数(请注意和通知的区别),该函数不需要主动调用
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user