mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-04-21 07:36:23 +08:00
fix android open notification and message callback in js
This commit is contained in:
parent
ec40fd3e58
commit
3e55f6f2c4
@ -91,7 +91,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
JSONObject data = notificationObject(message, extras);
|
JSONObject data = notificationObject(message, extras);
|
||||||
String js = String
|
String js = String
|
||||||
.format("window.plugins.jPushPlugin.pushCallback(%s);",
|
.format("window.plugins.jPushPlugin.recieveMessageInAndroidCallback(%s);",
|
||||||
data.toString());
|
data.toString());
|
||||||
try {
|
try {
|
||||||
instance.webView.sendJavascript(js);
|
instance.webView.sendJavascript(js);
|
||||||
@ -107,7 +107,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
JSONObject data = openNotificationObject(alert, extras);
|
JSONObject data = openNotificationObject(alert, extras);
|
||||||
String js = String
|
String js = String
|
||||||
.format("window.plugins.jPushPlugin.openNotificationCallback(%s);",
|
.format("window.plugins.jPushPlugin.openNotificationInAndroidCallback(%s);",
|
||||||
data.toString());
|
data.toString());
|
||||||
try {
|
try {
|
||||||
instance.webView.sendJavascript(js);
|
instance.webView.sendJavascript(js);
|
||||||
|
@ -76,7 +76,24 @@ JPushPlugin.prototype.setAlias = function(data){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.pushCallback = function(data){
|
JPushPlugin.prototype.recieveMessageInAndroidCallback = function(data){
|
||||||
|
try{
|
||||||
|
console.log("JPushPlugin:pushCallback--data:"+data);
|
||||||
|
var bToObj=JSON.parse(data);
|
||||||
|
var message = bToObj.message;
|
||||||
|
var extras = bToObj.extras;
|
||||||
|
|
||||||
|
console.log(message);
|
||||||
|
console.log(extras['cn.jpush.android.MSG_ID']);
|
||||||
|
console.log(extras['cn.jpush.android.CONTENT_TYPE']);
|
||||||
|
console.log(extras['cn.jpush.android.EXTRA']);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log("JPushPlugin:pushCallback "+exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.recieveMessageIniOSCallback = function(data){
|
||||||
try{
|
try{
|
||||||
console.log("JPushPlugin:pushCallback--data:"+data);
|
console.log("JPushPlugin:pushCallback--data:"+data);
|
||||||
var bToObj=JSON.parse(data);
|
var bToObj=JSON.parse(data);
|
||||||
@ -94,7 +111,27 @@ JPushPlugin.prototype.pushCallback = function(data){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
JPushPlugin.prototype.openNotificationCallback = function(data){
|
JPushPlugin.prototype.openNotificationInAndroidCallback = function(data){
|
||||||
|
try{
|
||||||
|
console.log(data);
|
||||||
|
var bToObj = JSON.parse(data);
|
||||||
|
var alert = bToObj.alert;
|
||||||
|
var extras = bToObj.extras;
|
||||||
|
console.log(alert);
|
||||||
|
|
||||||
|
console.log(extras['cn.jpush.android.MSG_ID']);
|
||||||
|
console.log(extras['app']);
|
||||||
|
console.log(extras['cn.jpush.android.NOTIFICATION_CONTENT_TITLE']);
|
||||||
|
console.log(extras['cn.jpush.android.EXTRA']);
|
||||||
|
console.log(extras['cn.jpush.android.PUSH_ID']);
|
||||||
|
console.log(extras['cn.jpush.android.NOTIFICATION_ID']);
|
||||||
|
console.log("JPushPlugin:openNotificationCallback is ready");
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.openNotificationIniOSCallback = function(data){
|
||||||
try{
|
try{
|
||||||
console.log(data);
|
console.log(data);
|
||||||
var bToObj = JSON.parse(data);
|
var bToObj = JSON.parse(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user