From 70e2d6d9e276ba36a8724ac1e13ac6519987baf1 Mon Sep 17 00:00:00 2001 From: zhangqinghe Date: Mon, 8 Dec 2014 10:05:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=82=B9=E5=87=BB=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=9A=84=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=88android=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/android/JPushPlugin.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/android/JPushPlugin.java b/src/android/JPushPlugin.java index 2f48493..4311ce2 100644 --- a/src/android/JPushPlugin.java +++ b/src/android/JPushPlugin.java @@ -67,7 +67,14 @@ public class JPushPlugin extends CordovaPlugin { JSONObject data = new JSONObject(); try { data.put("message", message); - data.put("extras", new JSONObject(extras)); + JSONObject jExtras = new JSONObject(); + for(Entry entry:extras.entrySet()){ + jExtras.put(entry.getKey(),entry.getValue()); + } + if(jExtras.length()>0) + { + data.put("extras", jExtras); + } } catch (JSONException e) { } @@ -77,9 +84,16 @@ public class JPushPlugin extends CordovaPlugin { private static JSONObject openNotificationObject(String alert, Map extras){ JSONObject data = new JSONObject(); - try { + try{ data.put("alert", alert); - data.put("extras", new JSONObject(extras)); + JSONObject jExtras = new JSONObject(); + for(Entry entry:extras.entrySet()){ + jExtras.put(entry.getKey(),entry.getValue()); + } + if(jExtras.length()>0) + { + data.put("extras", jExtras); + } } catch (JSONException e) { }