mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-21 04:42:53 +08:00
Merge pull request #100 from darkterrorooo/master
fix #99 android jpush.openNotification 事件调用两次
This commit is contained in:
commit
7cb3e22e14
@ -54,13 +54,13 @@
|
||||
}
|
||||
var onReceiveNotification = function(event){
|
||||
try{
|
||||
var alert
|
||||
var alertContent
|
||||
if(device.platform == "Android"){
|
||||
alert = window.plugins.jPushPlugin.receiveNotification.alert;
|
||||
alertContent = window.plugins.jPushPlugin.receiveNotification.alert;
|
||||
}else{
|
||||
alert = event.aps.alert;
|
||||
alertContent = event.aps.alert;
|
||||
}
|
||||
$("#notificationResult").html(alert);
|
||||
$("#notificationResult").html(alertContent);
|
||||
|
||||
}
|
||||
catch(exeption){
|
||||
|
@ -26,6 +26,8 @@ import cn.jpush.android.api.CustomPushNotificationBuilder;
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.data.JPushLocalNotification;
|
||||
import cn.jpush.android.api.TagAliasCallback;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class JPushPlugin extends CordovaPlugin {
|
||||
private final static List<String> methodList =
|
||||
@ -56,7 +58,9 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
|
||||
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
||||
private static JPushPlugin instance;
|
||||
private static String TAG = "Client JPushPlugin";
|
||||
|
||||
public static boolean bOpenNotificationAlert = true;
|
||||
public static String notificationAlert;
|
||||
public static Map<String, Object> notificationExtras=new HashMap<String, Object>();
|
||||
public static String openNotificationAlert;
|
||||
@ -73,12 +77,19 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
|
||||
//JPushPlugin.notificationAlert = alert;
|
||||
//JPushPlugin.notificationExtras = extras;
|
||||
if(JPushPlugin.openNotificationAlert != null){
|
||||
JPushPlugin.transmitOpen(JPushPlugin.openNotificationAlert, JPushPlugin.openNotificationExtras);
|
||||
}
|
||||
if(JPushPlugin.notificationAlert!=null){
|
||||
JPushPlugin.transmitReceive(JPushPlugin.notificationAlert, JPushPlugin.notificationExtras);
|
||||
}
|
||||
|
||||
if(JPushPlugin.bOpenNotificationAlert){
|
||||
|
||||
JPushPlugin.bOpenNotificationAlert = false;
|
||||
if(JPushPlugin.openNotificationAlert != null){
|
||||
JPushPlugin.transmitOpen(JPushPlugin.openNotificationAlert, JPushPlugin.openNotificationExtras);
|
||||
}
|
||||
if(JPushPlugin.notificationAlert!=null){
|
||||
JPushPlugin.transmitReceive(JPushPlugin.notificationAlert, JPushPlugin.notificationExtras);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//JPushInterface.init(cordova.getActivity().getApplicationContext());
|
||||
}
|
||||
@ -226,7 +237,7 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
JSONArray.class, CallbackContext.class);
|
||||
method.invoke(JPushPlugin.this, data, callbackContext);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
Log.e(TAG,e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
|
||||
JPushPlugin.bOpenNotificationAlert = true;
|
||||
JPushPlugin.openNotificationAlert = alert;
|
||||
JPushPlugin.openNotificationExtras = extras;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user