From 260c298f6b8eb004ebbc5ab0033a4840fe788d9e Mon Sep 17 00:00:00 2001 From: zhangqinghe Date: Mon, 26 Jan 2015 14:23:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=9F=E8=AE=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/android/JPushPlugin.java | 22 +++++++++++++++++++++- www/JPushPlugin.js | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/android/JPushPlugin.java b/src/android/JPushPlugin.java index b2b9214..f3b5f5b 100644 --- a/src/android/JPushPlugin.java +++ b/src/android/JPushPlugin.java @@ -48,7 +48,10 @@ public class JPushPlugin extends CordovaPlugin { "clearAllNotification", "addLocalNotification", "removeLocalNotification", - "clearLocalNotifications"); + "clearLocalNotifications", + "onResume", + "onPause", + "reportNotificationOpened"); private ExecutorService threadPool = Executors.newFixedThreadPool(1); private static JPushPlugin instance; @@ -252,6 +255,23 @@ public class JPushPlugin extends CordovaPlugin { String regID= JPushInterface.getRegistrationID(this.cordova.getActivity().getApplicationContext()); callbackContext.success(regID); + } + void onResume(JSONArray data, CallbackContext callbackContext) { + JPushInterface.onResume(this.cordova.getActivity()); + } + void onPause(JSONArray data, CallbackContext callbackContext) { + JPushInterface.onPause(this.cordova.getActivity()); + } + void reportNotificationOpened(JSONArray data, CallbackContext callbackContext) { + try { + String msgID; + msgID = data.getString(0); + JPushInterface.reportNotificationOpened(this.cordova.getActivity(),msgID); + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } void setTags(JSONArray data, CallbackContext callbackContext) { diff --git a/www/JPushPlugin.js b/www/JPushPlugin.js index 9d672c8..57dc420 100644 --- a/www/JPushPlugin.js +++ b/www/JPushPlugin.js @@ -149,6 +149,7 @@ JPushPlugin.prototype.receiveMessageInAndroidCallback = function(data){ console.log("JPushPlugin:pushCallback "+exception); } } + // JPushPlugin.prototype.openNotificationInAndroidCallback = function(data){ try{ @@ -253,6 +254,25 @@ JPushPlugin.prototype.clearLocalNotifications = function(){ this.call_native("clearLocalNotifications",data,null); } } +JPushPlugin.prototype.onResume = function(){ + if(device.platform == "Android") { + data=[] + this.call_native("onResume",data,null); + } +} +JPushPlugin.prototype.onPause = function(){ + if(device.platform == "Android") { + data=[] + this.call_native("onPause",data,null); + } +} + +JPushPlugin.prototype.reportNotificationOpened = function(msgID){ + if(device.platform == "Android") { + + this.call_native("reportNotificationOpened",[msgID],null); + } +} //iOS single