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 a5969e1..30c6c14 100644 --- a/src/android/JPushPlugin.java +++ b/src/android/JPushPlugin.java @@ -144,6 +144,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) {