mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-21 21:43:02 +08:00
fix #75
This commit is contained in:
parent
3868e0be35
commit
a3082d0475
@ -181,7 +181,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject data = notificationObject(message, extras);
|
JSONObject data = notificationObject(message, extras);
|
||||||
String format = "window.plugins.jPushPlugin.receiveMessageInAndroidCallback('%s');";
|
String format = "window.plugins.jPushPlugin.receiveMessageInAndroidCallback(%s);";
|
||||||
final String js = String.format(format, data.toString());
|
final String js = String.format(format, data.toString());
|
||||||
cordovaActivity.runOnUiThread(new Runnable() {
|
cordovaActivity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -198,10 +198,8 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
if (JPushPlugin.shouldCacheMsg) {
|
if (JPushPlugin.shouldCacheMsg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.i(TAG, "---------------- transmitOpen");
|
|
||||||
|
|
||||||
JSONObject data = openNotificationObject(alert, extras);
|
JSONObject data = openNotificationObject(alert, extras);
|
||||||
String format = "window.plugins.jPushPlugin.openNotificationInAndroidCallback('%s');";
|
String format = "window.plugins.jPushPlugin.openNotificationInAndroidCallback(%s);";
|
||||||
final String js = String.format(format, data.toString());
|
final String js = String.format(format, data.toString());
|
||||||
cordovaActivity.runOnUiThread(new Runnable() {
|
cordovaActivity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -217,7 +215,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject data = openNotificationObject(alert, extras);
|
JSONObject data = openNotificationObject(alert, extras);
|
||||||
String format = "window.plugins.jPushPlugin.receiveNotificationInAndroidCallback('%s');";
|
String format = "window.plugins.jPushPlugin.receiveNotificationInAndroidCallback(%s);";
|
||||||
final String js = String.format(format, data.toString());
|
final String js = String.format(format, data.toString());
|
||||||
cordovaActivity.runOnUiThread(new Runnable() {
|
cordovaActivity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -258,13 +256,6 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
boolean mode;
|
boolean mode;
|
||||||
try {
|
try {
|
||||||
mode = data.getBoolean(0);
|
mode = data.getBoolean(0);
|
||||||
// if (mode.equals("true")) {
|
|
||||||
// JPushInterface.setDebugMode(true);
|
|
||||||
// } else if (mode.equals("false")) {
|
|
||||||
// JPushInterface.setDebugMode(false);
|
|
||||||
// } else {
|
|
||||||
// callbackContext.error("error mode");
|
|
||||||
// }
|
|
||||||
JPushInterface.setDebugMode(mode);
|
JPushInterface.setDebugMode(mode);
|
||||||
callbackContext.success();
|
callbackContext.success();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -530,7 +521,12 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
String jsEvent = String.format(
|
String jsEvent = String.format(
|
||||||
"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%s)",
|
"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%s)",
|
||||||
data.toString());
|
data.toString());
|
||||||
instance.webView.sendJavascript(jsEvent);
|
cordovaActivity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
instance.webView.loadUrl("javascript:" + jsEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -188,17 +188,10 @@ JPushPlugin.prototype.receiveMessageIniOSCallback = function(data) {
|
|||||||
JPushPlugin.prototype.receiveMessageInAndroidCallback = function(data) {
|
JPushPlugin.prototype.receiveMessageInAndroidCallback = function(data) {
|
||||||
try {
|
try {
|
||||||
console.log("JPushPlugin:receiveMessageInAndroidCallback");
|
console.log("JPushPlugin:receiveMessageInAndroidCallback");
|
||||||
|
data = JSON.stringify(data);
|
||||||
var bToObj = JSON.parse(data);
|
var bToObj = JSON.parse(data);
|
||||||
this.receiveMessage = bToObj
|
this.receiveMessage = bToObj
|
||||||
cordova.fireDocumentEvent('jpush.receiveMessage', null);
|
cordova.fireDocumentEvent('jpush.receiveMessage', null);
|
||||||
//console.log(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) {
|
} catch(exception) {
|
||||||
console.log("JPushPlugin:pushCallback " + exception);
|
console.log("JPushPlugin:pushCallback " + exception);
|
||||||
}
|
}
|
||||||
@ -207,23 +200,10 @@ JPushPlugin.prototype.receiveMessageInAndroidCallback = function(data) {
|
|||||||
JPushPlugin.prototype.openNotificationInAndroidCallback = function(data) {
|
JPushPlugin.prototype.openNotificationInAndroidCallback = function(data) {
|
||||||
try {
|
try {
|
||||||
console.log("JPushPlugin:openNotificationInAndroidCallback");
|
console.log("JPushPlugin:openNotificationInAndroidCallback");
|
||||||
|
data = JSON.stringify(data);
|
||||||
var bToObj = JSON.parse(data);
|
var bToObj = JSON.parse(data);
|
||||||
this.openNotification = bToObj;
|
this.openNotification = bToObj;
|
||||||
cordova.fireDocumentEvent('jpush.openNotification', null);
|
cordova.fireDocumentEvent('jpush.openNotification', null);
|
||||||
|
|
||||||
//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) {
|
} catch(exception) {
|
||||||
console.log(exception);
|
console.log(exception);
|
||||||
}
|
}
|
||||||
@ -232,23 +212,10 @@ JPushPlugin.prototype.openNotificationInAndroidCallback = function(data) {
|
|||||||
JPushPlugin.prototype.receiveNotificationInAndroidCallback = function(data) {
|
JPushPlugin.prototype.receiveNotificationInAndroidCallback = function(data) {
|
||||||
try{
|
try{
|
||||||
console.log("JPushPlugin:receiveNotificationInAndroidCallback");
|
console.log("JPushPlugin:receiveNotificationInAndroidCallback");
|
||||||
|
data = JSON.stringify(data);
|
||||||
var bToObj = JSON.parse(data);
|
var bToObj = JSON.parse(data);
|
||||||
this.receiveNotification = bToObj;
|
this.receiveNotification = bToObj;
|
||||||
cordova.fireDocumentEvent('jpush.receiveNotification', null);
|
cordova.fireDocumentEvent('jpush.receiveNotification', null);
|
||||||
|
|
||||||
//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) {
|
} catch(exception) {
|
||||||
console.log(exception);
|
console.log(exception);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user