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