Add API setGeofenceInterval for Android

This commit is contained in:
JoshLi 2018-12-28 17:27:31 +08:00
parent 5a8a926c50
commit 16c3c96844
4 changed files with 56 additions and 3 deletions

View File

@ -7,7 +7,7 @@
- [设置保留最近通知条数](#设置保留最近通知条数)
- [本地通知](#本地通知)
- [获取推送连接状态](#获取推送连接状态)
- [地理围栏](#地理围栏)
## 获取集成日志(同时适用于 iOS
@ -215,4 +215,34 @@ window.JPush.getConnectionState(function (result) {
// 断开状态
}
})
```
```
## 地理围栏
### API - setGeofenceInterval
设置地理围栏监控周期最小3分钟最大1天。默认为15分钟当距离地理围栏边界小于1000米周期自动调整为3分钟。设置成功后一直使用设置周期不会进行调整。
#### 接口定义
```js
window.JPush.setGeofenceInterval(interval)
```
#### 参数说明
- interval: 监控周期,单位是毫秒。
### API - setMaxGeofenceNumber
设置最多允许保存的地理围栏数量超过最大限制后如果继续创建先删除最早创建的地理围栏。默认数量为10个允许设置最小1个最大100个。
#### 接口定义
```js
window.JPush.setMaxGeofenceNumber(maxNumber)
```
#### 参数说明
- maxNumber: 最多允许保存的地理围栏个数

View File

@ -627,6 +627,16 @@ public class JPushPlugin extends CordovaPlugin {
}
}
void setGeofenceInterval(JSONArray data, CallbackContext callbackContext) throws JSONException {
long interval = data.getLong(0);
JPushInterface.setGeofenceInterval(this.cordova.getActivity(), interval);
}
void setMaxGeofenceNumber(JSONArray data, CallbackContext callbackContext) throws JSONException {
int maxNumber = data.getInt(0);
JPushInterface.setMaxGeofenceNumber(mContext, maxNumber);
}
private boolean isValidHour(int hour) {
return !(hour < 0 || hour > 23);
}
@ -706,4 +716,5 @@ public class JPushPlugin extends CordovaPlugin {
return false;
}
}

View File

@ -14,7 +14,7 @@ import cn.jpush.android.api.JPushInterface;
public class JPushReceiver extends BroadcastReceiver {
private static final List<String> IGNORED_EXTRAS_KEYS = Arrays.asList("cn.jpush.android.TITLE",
"cn.jpush.android.MESSAGE", "cn.jpush.android.APPKEY", "cn.jpush.android.NOTIFICATION_CONTENT_TITLE");
"cn.jpush.android.MESSAGE", "cn.jpush.android.APPKEY", "cn.jpush.android.NOTIFICATION_CONTENT_TITLE","key_show_entity","platform");
@Override
public void onReceive(Context context, Intent intent) {

View File

@ -463,6 +463,18 @@ JPushPlugin.prototype.setPushTime = function(weekdays, startHour, endHour) {
}
};
JPushPlugin.prototype.setGeofenceInterval = function(interval) {
if (device.platform === "Android") {
this.callNative("setGeofenceInterval", [interval], null);
}
};
JPushPlugin.prototype.setMaxGeofenceNumber = function(maxNumber) {
if (device.platform === "Android") {
this.callNative("setMaxGeofenceNumber", [maxNumber], null);
}
};
if (!window.plugins) {
window.plugins = {};
}