diff --git a/example/index.html b/example/index.html
index 94b3e17..e4c3cf5 100644
--- a/example/index.html
+++ b/example/index.html
@@ -38,8 +38,16 @@
}
var initiateUI = function(){
- window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
-
+ try{
+ window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
+// var extras={"name":"json"};
+// window.plugins.jPushPlugin.addLocalNotification(1,"hh","ln",1111,1000*60,extras);
+// window.plugins.jPushPlugin.removeLocalNotification(1111);
+// window.plugins.jPushPlugin.clearLocalNotifications();
+ }
+ catch(exception){
+ console.log(exception);
+ }
//test android interface
//window.plugins.jPushPlugin.stopPush()
diff --git a/src/android/JPushPlugin.java b/src/android/JPushPlugin.java
index b820e34..a60ddc5 100644
--- a/src/android/JPushPlugin.java
+++ b/src/android/JPushPlugin.java
@@ -44,7 +44,10 @@ public class JPushPlugin extends CordovaPlugin {
"isPushStopped",
"setLatestNotificationNum",
"setPushTime",
- "clearAllNotification");
+ "clearAllNotification",
+ "addLocalNotification",
+ "removeLocalNotification",
+ "clearLocalNotifications");
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
private static JPushPlugin instance;
@@ -373,6 +376,41 @@ public class JPushPlugin extends CordovaPlugin {
callbackContext.error("error id");
}
}
+ void addLocalNotification(JSONArray data,
+ CallbackContext callbackContext) throws JSONException{
+ //builderId,content,title,notificaitonID,broadcastTime,extras
+
+ int builderId=data.getInt(0);
+ String content =data.getString(1);
+ String title = data.getString(2);
+ int notificationID= data.getInt(3);
+ int broadcastTime=data.getInt(4);
+ JSONObject extras=data.getJSONObject(5);
+
+ JPushLocalNotification ln = new JPushLocalNotification();
+ ln.setBuilderId(builderId);
+ ln.setContent(content);
+ ln.setTitle(title);
+ ln.setNotificationId(notificationID) ;
+ ln.setBroadcastTime(System.currentTimeMillis() + broadcastTime);
+
+ ln.setExtras(extras.toString()) ;
+ JPushInterface.addLocalNotification(this.cordova.getActivity(), ln);
+
+ }
+ void removeLocalNotification(JSONArray data,
+ CallbackContext callbackContext) throws JSONException{
+
+ int notificationID=data.getInt(0);
+ JPushInterface.removeLocalNotification(this.cordova.getActivity(),notificationID);
+
+ }
+ void clearLocalNotifications(JSONArray data,
+ CallbackContext callbackContext){
+
+ JPushInterface.clearLocalNotifications(this.cordova.getActivity());
+
+ }
private final TagAliasCallback mTagWithAliasCallback = new TagAliasCallback() {
diff --git a/www/JPushPlugin.js b/www/JPushPlugin.js
index 83290b3..d8ee343 100644
--- a/www/JPushPlugin.js
+++ b/www/JPushPlugin.js
@@ -223,6 +223,23 @@ JPushPlugin.prototype.setDebugMode = function(mode){
this.call_native("setDebugMode",[mode],null);
}
}
+JPushPlugin.prototype.addLocalNotification = function(builderId,content,title,notificaitonID,broadcastTime,extras){
+ if(device.platform == "Android") {
+ data=[builderId,content,title,notificaitonID,broadcastTime,extras];
+ this.call_native("addLocalNotification",data,null);
+ }
+}
+JPushPlugin.prototype.removeLocalNotification = function(notificationID){
+ if(device.platform == "Android") {
+ this.call_native("removeLocalNotification",[notificationID],null);
+ }
+}
+JPushPlugin.prototype.clearLocalNotifications = function(){
+ if(device.platform == "Android") {
+ data=[]
+ this.call_native("clearLocalNotifications",data,null);
+ }
+}
//iOS single