Skip to content

Commit 894c7d7

Browse files
authored
Merge pull request #373 from jpush/dev
Dev
2 parents 82d68c3 + aabc145 commit 894c7d7

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

doc/Android_detail_api.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- [通知栏样式定制](#通知栏样式定制)
77
- [设置保留最近通知条数](#设置保留最近通知条数)
88
- [本地通知](#本地通知)
9+
- [获取推送连接状态](#获取推送连接状态)
10+
911

1012
## 获取集成日志(同时适用于 iOS)
1113

@@ -185,4 +187,32 @@ window.JPush.clearLocalNotifications() // 同时适用于 iOS
185187
- title: 设置本地通知的 title。
186188
- notificationID: 设置本地通知的 ID(不要为 0)。
187189
- broadcastTime: 设置本地通知触发时间,为距离当前时间的数值,单位是毫秒。
188-
- extras: 设置额外的数据信息 extras 为 json 字符串。
190+
- extras: 设置额外的数据信息 extras 为 json 字符串。
191+
192+
## 获取推送连接状态
193+
194+
### API - getConnectionState
195+
196+
开发者可以使用此功能获取当前 Push 服务的连接状态
197+
198+
#### 接口定义
199+
200+
```js
201+
window.JPush.getConnectionState(callback)
202+
```
203+
204+
#### 参数说明
205+
206+
- callback: 回调函数,用来通知 JPush 的推送服务是否开启。
207+
208+
#### 代码示例
209+
210+
```js
211+
window.JPush.getConnectionState(function (result) {
212+
if (result == 0) {
213+
// 链接状态
214+
} else {
215+
// 断开状态
216+
}
217+
})
218+
```

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.4.3",
3+
"version": "3.4.5",
44
"description": "JPush for cordova plugin",
55
"cordova": {
66
"id": "jpush-phonegap-plugin",

plugin.xml

Lines changed: 2 additions & 2 deletions
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.4.3">
5+
version="3.4.5">
66

77
<name>JPush</name>
88
<description>JPush for cordova plugin</description>
@@ -202,7 +202,7 @@
202202
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
203203
</config-file>
204204

205-
<lib-file src="src/android/libs/jpush-android-3.1.5.jar" />
205+
<lib-file src="src/android/libs/jpush-android-3.1.6.jar" />
206206

207207
<source-file src="src/android/JPushReceiver.java" target-dir="app/src/main/java/cn/jiguang/cordova/push" />
208208
<source-file src="src/android/JPushPlugin.java" target-dir="app/src/main/java/cn/jiguang/cordova/push" />

src/android/JPushPlugin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,11 @@ void checkTagBindState(JSONArray data, CallbackContext callbackContext) {
523523

524524
void getConnectionState(JSONArray data, CallbackContext callback) {
525525
boolean isConnected = JPushInterface.getConnectionState(cordovaActivity.getApplicationContext());
526-
callback.success(String.valueOf(isConnected));
526+
if (isConnected) {
527+
callback.success(1);
528+
} else {
529+
callback.success(0);
530+
}
527531
}
528532

529533
/**

0 commit comments

Comments
 (0)