diff --git a/doc/Android_detail_api.md b/doc/Android_detail_api.md index 4edc464..9697f99 100644 --- a/doc/Android_detail_api.md +++ b/doc/Android_detail_api.md @@ -245,4 +245,19 @@ window.JPush.setMaxGeofenceNumber(maxNumber) #### 参数说明 -- maxNumber: 最多允许保存的地理围栏个数 \ No newline at end of file +- maxNumber: 最多允许保存的地理围栏个数 + + +### API - setBadgeNumber + +设置App角标,目前仅华为系手机支持。 + +#### 接口定义 + +```js +window.JPush.setBadgeNumber(badgeNumb) +``` + +#### 参数说明 + +- badgeNumb: 角标显示数字,小于或等0,角标显示数字清楚 \ No newline at end of file diff --git a/example/index.html b/example/index.html index a5682c6..e8b9960 100644 --- a/example/index.html +++ b/example/index.html @@ -49,6 +49,7 @@ } }; + var badgeNumb = 0; var onOpenNotification = function(event) { try { var alertContent; @@ -57,6 +58,11 @@ } else { alertContent = event.aps.alert; } + + badgeNumb = badgeNumb - 1; + badgeNumb = badgeNumb<=0 ? 0 : badgeNumb; + window.JPush.setBadgeNumber(badgeNumb); + alert("open Notification:" + alertContent); } catch (exception) { console.log("JPushPlugin:onOpenNotification" + exception); @@ -72,6 +78,9 @@ alertContent = event.aps.alert; } $("#notificationResult").html(alertContent); + + badgeNumb = badgeNumb + 1; + window.JPush.setBadgeNumber(badgeNumb); } catch (exception) { console.log(exception) } @@ -86,11 +95,24 @@ message = event.content; } $("#messageResult").html(message); + + badgeNumb = badgeNumb + 1; + window.JPush.setBadgeNumber(badgeNumb); } catch (exception) { console.log("JPushPlugin:onReceiveMessage-->" + exception); } }; + var onResume = function(event){ + try { + badgeNumb = 0 + window.JPush.setBadgeNumber(0); + + } catch (exception) { + console.log("onResume-->" + exception); + } + } + var initiateUI = function() { try { window.JPush.init(); @@ -184,6 +206,7 @@ document.addEventListener("jpush.openNotification", onOpenNotification, false); document.addEventListener("jpush.receiveNotification", onReceiveNotification, false); document.addEventListener("jpush.receiveMessage", onReceiveMessage, false); + document.addEventListener("resume", onResume, false); diff --git a/package.json b/package.json index 80bcfdf..cba6d7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jpush-phonegap-plugin", - "version": "3.7.3", + "version": "3.7.4", "description": "JPush for cordova plugin", "cordova": { "id": "jpush-phonegap-plugin", diff --git a/plugin.xml b/plugin.xml index 323fe03..6a982fc 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="3.7.4"> JPush JPush for cordova plugin @@ -105,6 +105,9 @@ + + + @@ -196,6 +199,9 @@ + + + diff --git a/src/android/JPushPlugin.java b/src/android/JPushPlugin.java index 867d511..8f39a44 100644 --- a/src/android/JPushPlugin.java +++ b/src/android/JPushPlugin.java @@ -637,6 +637,11 @@ public class JPushPlugin extends CordovaPlugin { JPushInterface.setMaxGeofenceNumber(mContext, maxNumber); } + void setBadgeNumber(JSONArray data, CallbackContext callbackContext) throws JSONException { + int badgeNumb = data.getInt(0); + JPushInterface.setBadgeNumber(mContext, badgeNumb); + } + private boolean isValidHour(int hour) { return !(hour < 0 || hour > 23); } diff --git a/src/android/libs/jpush-android-3.3.8.jar b/src/android/libs/jpush-android-3.3.8.jar deleted file mode 100755 index 6e2d51a..0000000 Binary files a/src/android/libs/jpush-android-3.3.8.jar and /dev/null differ diff --git a/src/android/libs/jpush-android-3.5.8.jar b/src/android/libs/jpush-android-3.5.8.jar new file mode 100644 index 0000000..dc788eb Binary files /dev/null and b/src/android/libs/jpush-android-3.5.8.jar differ diff --git a/www/JPushPlugin.js b/www/JPushPlugin.js index b34050f..6a6d369 100644 --- a/www/JPushPlugin.js +++ b/www/JPushPlugin.js @@ -475,6 +475,13 @@ JPushPlugin.prototype.setMaxGeofenceNumber = function(maxNumber) { } }; +//设置角标 +JPushPlugin.prototype.setBadgeNumber = function(badgeNumb) { + if (device.platform === "Android") { + this.callNative("setBadgeNumber", [badgeNumb], null); + } +}; + if (!window.plugins) { window.plugins = {}; }