From 46e0c1879c6e2441c7918d2499034c0d184cdbcc Mon Sep 17 00:00:00 2001 From: zhangqinghe Date: Tue, 27 Jan 2015 18:19:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=89=93?= =?UTF-8?q?=E5=BC=80=E9=80=9A=E7=9F=A5=E7=9A=84event=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/index.html | 15 ++++++++++++++- src/android/JPushPlugin.java | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/example/index.html b/example/index.html index 0d80ef0..f7d2741 100644 --- a/example/index.html +++ b/example/index.html @@ -26,6 +26,17 @@ console.log(exception) } } + var onOpenNotification = function(event){ + try{ + var alert = event.alert; + var extras = event.extras; + console.log(alert); + console.log(extras); + } + catch(exeption){ + console.log(exception) + } + } var onGetRegistradionID = function(data) { try{ console.log("JPushPlugin:registrationID is "+data) @@ -92,7 +103,9 @@ }) } document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false); - document.addEventListener("deviceready", onDeviceReady, false); + document.addEventListener("deviceready", onDeviceReady, false); + document.addEventListener("jpush.openNotification", onOpenNotification, false); + diff --git a/src/android/JPushPlugin.java b/src/android/JPushPlugin.java index f3b5f5b..5c4b892 100644 --- a/src/android/JPushPlugin.java +++ b/src/android/JPushPlugin.java @@ -139,6 +139,11 @@ public class JPushPlugin extends CordovaPlugin { data.toString()); try { instance.webView.sendJavascript(js); + + String jsEvent=String + .format("cordova.fireDocumentEvent('jpush.openNotification',%s)", + data.toString()); + instance.webView.sendJavascript(jsEvent); } catch (NullPointerException e) { } catch (Exception e) { From 1b93f5e026aaf4d7c69332945114ba10b1676b0a Mon Sep 17 00:00:00 2001 From: zhangqinghe Date: Tue, 27 Jan 2015 18:31:05 +0800 Subject: [PATCH 2/2] delete openNotificaiton error simple --- example/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/index.html b/example/index.html index f7d2741..cc4adb1 100644 --- a/example/index.html +++ b/example/index.html @@ -31,7 +31,7 @@ var alert = event.alert; var extras = event.extras; console.log(alert); - console.log(extras); + //console.log(extras); } catch(exeption){ console.log(exception)