mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-21 21:43:02 +08:00
替换已废弃的方法
This commit is contained in:
parent
c5c6b3da06
commit
ff090d63f6
@ -58,6 +58,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
||||||
private static JPushPlugin instance;
|
private static JPushPlugin instance;
|
||||||
|
private static Activity cordovaActivity;
|
||||||
private static String TAG = "JPushPlugin";
|
private static String TAG = "JPushPlugin";
|
||||||
|
|
||||||
private static boolean shouldCacheMsg = false;
|
private static boolean shouldCacheMsg = false;
|
||||||
@ -78,7 +79,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
Log.i(TAG, "---------------- initialize" + "-" + JPushPlugin.openNotificationAlert + "-" + JPushPlugin.notificationAlert);
|
Log.i(TAG, "---------------- initialize" + "-" + JPushPlugin.openNotificationAlert + "-" + JPushPlugin.notificationAlert);
|
||||||
|
|
||||||
shouldCacheMsg = false;
|
cordovaActivity = this.cordova.getActivity();
|
||||||
|
|
||||||
//如果同时缓存了打开事件openNotificationAlert 和 消息事件notificationAlert,只向UI 发 打开事件。
|
//如果同时缓存了打开事件openNotificationAlert 和 消息事件notificationAlert,只向UI 发 打开事件。
|
||||||
//这样做是为了和iOS 统一
|
//这样做是为了和iOS 统一
|
||||||
@ -170,18 +171,14 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject data = notificationObject(message, extras);
|
JSONObject data = notificationObject(message, extras);
|
||||||
String js = String.format(
|
String format = "window.plugins.jPushPlugin.receiveMessageInAndroidCallback('%s');";
|
||||||
"window.plugins.jPushPlugin.receiveMessageInAndroidCallback('%s');",
|
final String js = String.format(format, data.toString());
|
||||||
data.toString());
|
cordovaActivity.runOnUiThread(new Runnable() {
|
||||||
try {
|
@Override
|
||||||
instance.webView.sendJavascript(js);
|
public void run() {
|
||||||
// String jsEvent=String
|
instance.webView.loadUrl("javascript:" + js);
|
||||||
// .format("cordova.fireDocumentEvent('jpush.receiveMessage',%s)",
|
}
|
||||||
// data.toString());
|
});
|
||||||
// instance.webView.sendJavascript(jsEvent);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transmitOpen(String alert, Map<String, Object> extras) {
|
static void transmitOpen(String alert, Map<String, Object> extras) {
|
||||||
@ -194,18 +191,14 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
Log.i(TAG, "---------------- transmitOpen");
|
Log.i(TAG, "---------------- transmitOpen");
|
||||||
|
|
||||||
JSONObject data = openNotificationObject(alert, extras);
|
JSONObject data = openNotificationObject(alert, extras);
|
||||||
String js = String.format(
|
String format = "window.plugins.jPushPlugin.openNotificationInAndroidCallback('%s');";
|
||||||
"window.plugins.jPushPlugin.openNotificationInAndroidCallback('%s');",
|
final String js = String.format(format, data.toString());
|
||||||
data.toString());
|
cordovaActivity.runOnUiThread(new Runnable() {
|
||||||
try {
|
@Override
|
||||||
instance.webView.sendJavascript(js);
|
public void run() {
|
||||||
// String jsEvent=String
|
instance.webView.loadUrl("javascript:" + js);
|
||||||
// .format("cordova.fireDocumentEvent('jpush.openNotification',%s)",
|
}
|
||||||
// data.toString());
|
});
|
||||||
// instance.webView.sendJavascript(jsEvent);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
JPushPlugin.openNotificationAlert = null;
|
JPushPlugin.openNotificationAlert = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,15 +210,14 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject data = openNotificationObject(alert, extras);
|
JSONObject data = openNotificationObject(alert, extras);
|
||||||
String js = String.format(
|
String format = "window.plugins.jPushPlugin.receiveNotificationInAndroidCallback('%s');";
|
||||||
"window.plugins.jPushPlugin.receiveNotificationInAndroidCallback('%s');",
|
final String js = String.format(format, data.toString());
|
||||||
data.toString());
|
cordovaActivity.runOnUiThread(new Runnable() {
|
||||||
Log.i(TAG, "--------->" + js);
|
@Override
|
||||||
try {
|
public void run() {
|
||||||
instance.webView.sendJavascript(js);
|
instance.webView.loadUrl("javascript:" + js);
|
||||||
} catch (Exception e) {
|
}
|
||||||
e.printStackTrace();
|
});
|
||||||
}
|
|
||||||
JPushPlugin.notificationAlert = null;
|
JPushPlugin.notificationAlert = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user