mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-22 05:53:04 +08:00
Merge branch 'dev'
This commit is contained in:
commit
85e3a23f88
@ -245,4 +245,19 @@ window.JPush.setMaxGeofenceNumber(maxNumber)
|
|||||||
|
|
||||||
#### 参数说明
|
#### 参数说明
|
||||||
|
|
||||||
- maxNumber: 最多允许保存的地理围栏个数
|
- maxNumber: 最多允许保存的地理围栏个数
|
||||||
|
|
||||||
|
|
||||||
|
### API - setBadgeNumber
|
||||||
|
|
||||||
|
设置App角标,目前仅华为系手机支持。
|
||||||
|
|
||||||
|
#### 接口定义
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.JPush.setBadgeNumber(badgeNumb)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 参数说明
|
||||||
|
|
||||||
|
- badgeNumb: 角标显示数字,小于或等0,角标显示数字清楚
|
@ -49,6 +49,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var badgeNumb = 0;
|
||||||
var onOpenNotification = function(event) {
|
var onOpenNotification = function(event) {
|
||||||
try {
|
try {
|
||||||
var alertContent;
|
var alertContent;
|
||||||
@ -57,6 +58,11 @@
|
|||||||
} else {
|
} else {
|
||||||
alertContent = event.aps.alert;
|
alertContent = event.aps.alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
badgeNumb = badgeNumb - 1;
|
||||||
|
badgeNumb = badgeNumb<=0 ? 0 : badgeNumb;
|
||||||
|
window.JPush.setBadgeNumber(badgeNumb);
|
||||||
|
|
||||||
alert("open Notification:" + alertContent);
|
alert("open Notification:" + alertContent);
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
console.log("JPushPlugin:onOpenNotification" + exception);
|
console.log("JPushPlugin:onOpenNotification" + exception);
|
||||||
@ -72,6 +78,9 @@
|
|||||||
alertContent = event.aps.alert;
|
alertContent = event.aps.alert;
|
||||||
}
|
}
|
||||||
$("#notificationResult").html(alertContent);
|
$("#notificationResult").html(alertContent);
|
||||||
|
|
||||||
|
badgeNumb = badgeNumb + 1;
|
||||||
|
window.JPush.setBadgeNumber(badgeNumb);
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
console.log(exception)
|
console.log(exception)
|
||||||
}
|
}
|
||||||
@ -86,11 +95,24 @@
|
|||||||
message = event.content;
|
message = event.content;
|
||||||
}
|
}
|
||||||
$("#messageResult").html(message);
|
$("#messageResult").html(message);
|
||||||
|
|
||||||
|
badgeNumb = badgeNumb + 1;
|
||||||
|
window.JPush.setBadgeNumber(badgeNumb);
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
console.log("JPushPlugin:onReceiveMessage-->" + 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() {
|
var initiateUI = function() {
|
||||||
try {
|
try {
|
||||||
window.JPush.init();
|
window.JPush.init();
|
||||||
@ -184,6 +206,7 @@
|
|||||||
document.addEventListener("jpush.openNotification", onOpenNotification, false);
|
document.addEventListener("jpush.openNotification", onOpenNotification, false);
|
||||||
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
|
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
|
||||||
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false);
|
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false);
|
||||||
|
document.addEventListener("resume", onResume, false);
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "3.7.3",
|
"version": "3.7.4",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "jpush-phonegap-plugin",
|
"id": "jpush-phonegap-plugin",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="jpush-phonegap-plugin"
|
id="jpush-phonegap-plugin"
|
||||||
version="3.7.3">
|
version="3.7.4">
|
||||||
|
|
||||||
<name>JPush</name>
|
<name>JPush</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
@ -105,6 +105,9 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||||
|
|
||||||
|
<!--华为角标-->
|
||||||
|
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE "/>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<config-file target="AndroidManifest.xml" parent="/manifest/application" mode="merge">
|
<config-file target="AndroidManifest.xml" parent="/manifest/application" mode="merge">
|
||||||
@ -196,6 +199,9 @@
|
|||||||
|
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
<receiver android:name="cn.jpush.android.service.AlarmReceiver" android:exported="false"/>
|
<receiver android:name="cn.jpush.android.service.AlarmReceiver" android:exported="false"/>
|
||||||
|
|
||||||
|
<!-- 3.5.0新增,用于定时展示功能 -->
|
||||||
|
<receiver android:name="cn.jpush.android.service.SchedulerReceiver" android:exported="false"/>
|
||||||
|
|
||||||
<!--since 3.3.0 接收JPush相关事件-->
|
<!--since 3.3.0 接收JPush相关事件-->
|
||||||
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
|
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
|
||||||
|
@ -637,6 +637,11 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
JPushInterface.setMaxGeofenceNumber(mContext, maxNumber);
|
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) {
|
private boolean isValidHour(int hour) {
|
||||||
return !(hour < 0 || hour > 23);
|
return !(hour < 0 || hour > 23);
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
BIN
src/android/libs/jpush-android-3.5.8.jar
Normal file
BIN
src/android/libs/jpush-android-3.5.8.jar
Normal file
Binary file not shown.
@ -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) {
|
if (!window.plugins) {
|
||||||
window.plugins = {};
|
window.plugins = {};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user