Skip to content

Commit 85e3a23

Browse files
committed
Merge branch 'dev'
2 parents 74fea46 + 206f2ac commit 85e3a23

File tree

8 files changed

+59
-3
lines changed

8 files changed

+59
-3
lines changed

doc/Android_detail_api.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,19 @@ window.JPush.setMaxGeofenceNumber(maxNumber)
245245

246246
#### 参数说明
247247

248-
- maxNumber: 最多允许保存的地理围栏个数
248+
- maxNumber: 最多允许保存的地理围栏个数
249+
250+
251+
### API - setBadgeNumber
252+
253+
设置App角标,目前仅华为系手机支持。
254+
255+
#### 接口定义
256+
257+
```js
258+
window.JPush.setBadgeNumber(badgeNumb)
259+
```
260+
261+
#### 参数说明
262+
263+
- badgeNumb: 角标显示数字,小于或等0,角标显示数字清楚

example/index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
}
5050
};
5151

52+
var badgeNumb = 0;
5253
var onOpenNotification = function(event) {
5354
try {
5455
var alertContent;
@@ -57,6 +58,11 @@
5758
} else {
5859
alertContent = event.aps.alert;
5960
}
61+
62+
badgeNumb = badgeNumb - 1;
63+
badgeNumb = badgeNumb<=0 ? 0 : badgeNumb;
64+
window.JPush.setBadgeNumber(badgeNumb);
65+
6066
alert("open Notification:" + alertContent);
6167
} catch (exception) {
6268
console.log("JPushPlugin:onOpenNotification" + exception);
@@ -72,6 +78,9 @@
7278
alertContent = event.aps.alert;
7379
}
7480
$("#notificationResult").html(alertContent);
81+
82+
badgeNumb = badgeNumb + 1;
83+
window.JPush.setBadgeNumber(badgeNumb);
7584
} catch (exception) {
7685
console.log(exception)
7786
}
@@ -86,11 +95,24 @@
8695
message = event.content;
8796
}
8897
$("#messageResult").html(message);
98+
99+
badgeNumb = badgeNumb + 1;
100+
window.JPush.setBadgeNumber(badgeNumb);
89101
} catch (exception) {
90102
console.log("JPushPlugin:onReceiveMessage-->" + exception);
91103
}
92104
};
93105

106+
var onResume = function(event){
107+
try {
108+
badgeNumb = 0
109+
window.JPush.setBadgeNumber(0);
110+
111+
} catch (exception) {
112+
console.log("onResume-->" + exception);
113+
}
114+
}
115+
94116
var initiateUI = function() {
95117
try {
96118
window.JPush.init();
@@ -184,6 +206,7 @@
184206
document.addEventListener("jpush.openNotification", onOpenNotification, false);
185207
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
186208
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false);
209+
document.addEventListener("resume", onResume, false);
187210
</script>
188211
</head>
189212

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jpush-phonegap-plugin",
3-
"version": "3.7.3",
3+
"version": "3.7.4",
44
"description": "JPush for cordova plugin",
55
"cordova": {
66
"id": "jpush-phonegap-plugin",

plugin.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
id="jpush-phonegap-plugin"
5-
version="3.7.3">
5+
version="3.7.4">
66

77
<name>JPush</name>
88
<description>JPush for cordova plugin</description>
@@ -105,6 +105,9 @@
105105
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
106106
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
107107
<uses-permission android:name="android.permission.GET_TASKS" />
108+
109+
<!--华为角标-->
110+
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE "/>
108111
</config-file>
109112

110113
<config-file target="AndroidManifest.xml" parent="/manifest/application" mode="merge">
@@ -196,6 +199,9 @@
196199

197200
<!-- Required SDK核心功能-->
198201
<receiver android:name="cn.jpush.android.service.AlarmReceiver" android:exported="false"/>
202+
203+
<!-- 3.5.0新增,用于定时展示功能 -->
204+
<receiver android:name="cn.jpush.android.service.SchedulerReceiver" android:exported="false"/>
199205

200206
<!--since 3.3.0 接收JPush相关事件-->
201207
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">

src/android/JPushPlugin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ void setMaxGeofenceNumber(JSONArray data, CallbackContext callbackContext) throw
637637
JPushInterface.setMaxGeofenceNumber(mContext, maxNumber);
638638
}
639639

640+
void setBadgeNumber(JSONArray data, CallbackContext callbackContext) throws JSONException {
641+
int badgeNumb = data.getInt(0);
642+
JPushInterface.setBadgeNumber(mContext, badgeNumb);
643+
}
644+
640645
private boolean isValidHour(int hour) {
641646
return !(hour < 0 || hour > 23);
642647
}
-201 KB
Binary file not shown.
267 KB
Binary file not shown.

www/JPushPlugin.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,13 @@ JPushPlugin.prototype.setMaxGeofenceNumber = function(maxNumber) {
475475
}
476476
};
477477

478+
//设置角标
479+
JPushPlugin.prototype.setBadgeNumber = function(badgeNumb) {
480+
if (device.platform === "Android") {
481+
this.callNative("setBadgeNumber", [badgeNumb], null);
482+
}
483+
};
484+
478485
if (!window.plugins) {
479486
window.plugins = {};
480487
}

0 commit comments

Comments
 (0)