diff --git a/example/index.html b/example/index.html index a6d04b5..d7b1ff6 100644 --- a/example/index.html +++ b/example/index.html @@ -13,7 +13,7 @@ var onDeviceReady = function(){ console.log("Device ready!") initiateUI(); - } + } var onTagsWithAlias = function(event){ try{ console.log("onTagsWithAlias"); @@ -37,9 +37,20 @@ } } var initiateUI = function(){ + window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID); - + //test android interface + //window.plugins.jPushPlugin.getNotification(onNotification); + //window.plugins.jPushPlugin.stopPush() + //window.plugins.jPushPlugin.resumePush(); + //window.plugins.jPushPlugin.clearAllNoticication(); + //window.plugins.jPushPlugin.setLatestNotificationNum(5); + //window.plugins.jPushPlugin.stopPush(); + //window.plugins.jPushPlugin.isPushStopped(onIsPushStopped); + //window.plugins.jPushPlugin.init(); + //window.plugins.jPushPlugin.setDebugable(true); //window.plugins.jPushPlugin.startLogPageView("mianPage"); + $("#setTagWithAliasButton").click(function(ev) { try{ var tag1 = $("#tagText1").attr("value"); @@ -61,8 +72,8 @@ dd.push(tag3); } } - //window.plugins.jPushPlugin.setTagsWithAlias(dd,alias); - window.plugins.jPushPlugin.setTags(dd); + window.plugins.jPushPlugin.setTagsWithAlias(dd,alias); + } catch(exception){ console.log(exception); diff --git a/src/android/JPushPlugin.java b/src/android/JPushPlugin.java index 5332172..7f17ce8 100644 --- a/src/android/JPushPlugin.java +++ b/src/android/JPushPlugin.java @@ -42,13 +42,14 @@ public class JPushPlugin extends CordovaPlugin { "resumePush", "isPushStopped", "setLatestNotificationNum", - "setPushTime"); + "setPushTime", + "clearAllNotification"); private ExecutorService threadPool = Executors.newFixedThreadPool(1); private static JPushPlugin instance; public static String notificationAlert; - public static Map notificationExtras; + public static Map notificationExtras=new HashMap(); public JPushPlugin() { instance = this; @@ -146,8 +147,12 @@ public class JPushPlugin extends CordovaPlugin { void isPushStopped(JSONArray data, CallbackContext callbackContext){ - JPushInterface.isPushStopped(this.cordova.getActivity().getApplicationContext()); - callbackContext.success(); + boolean isStoped =JPushInterface.isPushStopped(this.cordova.getActivity().getApplicationContext()); + if(isStoped){ + callbackContext.success(1); + }else{ + callbackContext.success(0); + } } void setLatestNotificationNum(JSONArray data, diff --git a/www/JPushPlugin.js b/www/JPushPlugin.js index 5dcf9e0..49e82e7 100644 --- a/www/JPushPlugin.js +++ b/www/JPushPlugin.js @@ -18,12 +18,16 @@ JPushPlugin.prototype.call_native = function(name, args, callback){ return ret; } -JPushPlugin.prototype.startLogPageView = function(data){ - this.call_native( "startLogPageView",[data],null); +JPushPlugin.prototype.startLogPageView = function(data){ + if(this.isPlatformIOS()){ + this.call_native( "startLogPageView",[data],null); + } } JPushPlugin.prototype.stopLogPageView = function(data){ - this.call_native( "stopLogPageView",[data],null); + if(this.isPlatformIOS()){ + this.call_native( "stopLogPageView",[data],null); + } } JPushPlugin.prototype.setTagsWithAlias = function(tags,alias){ @@ -88,8 +92,77 @@ JPushPlugin.prototype.pushCallback = function(data){ console.log(exception); } } -//android -//ios +//android single + +JPushPlugin.prototype.getNotification = function (callback) { + if(device.platform == "Android") { + data=[]; + this.call_native("getNotification",data,callback); + } +} + +JPushPlugin.prototype.setBasicPushNotificationBuilder = function(){ + if(device.platform == "Android") { + data=[] + this.call_native("setBasicPushNotificationBuilder",data,null); + } +} + +JPushPlugin.prototype.setCustomPushNotificationBuilder = function(){ + if(device.platform == "Android") { + data=[]; + this.call_native("setCustomPushNotificationBuilder",data,null); + } +} + +JPushPlugin.prototype.stopPush = function(){ + if(device.platform == "Android") { + data=[]; + this.call_native("stopPush",data,null); + } +} + +JPushPlugin.prototype.resumePush = function(){ + if(device.platform == "Android") { + data=[] + this.call_native("resumePush",data,null); + } +} + +JPushPlugin.prototype.clearAllNoticication = function(){ + if(device.platform == "Android") { + data=[] + this.call_native("clearAllNotification",data,null); + } +} + +JPushPlugin.prototype.setLatestNotificationNum = function(num){ + if(device.platform == "Android") { + this.call_native("setLatestNotificationNum",[num],null); + } +} + +JPushPlugin.prototype.isPushStopped = function(callback){ + if(device.platform == "Android") { + data=[]; + this.call_native("isPushStopped",data,callback) + } +} + +JPushPlugin.prototype.init = function(){ + if(device.platform == "Android") { + data=[]; + this.call_native("init",data,null); + } +} + +JPushPlugin.prototype.setDebugable = function(mode){ + if(device.platform == "Android") { + this.call_native("setDebugable",[mode],null); + } +} + +//ios single if(!window.plugins){