From cf4d5de33cbd2a444492ed77e1a8361d80120116 Mon Sep 17 00:00:00 2001 From: huangshuni <15889638723@163.com> Date: Thu, 14 May 2026 17:26:15 +0800 Subject: [PATCH] chore: release jpush-phonegap-plugin v1.0 --- CHANGELOG.md | 6 ++++++ plugin.xml | 6 +++--- src/android/JPushEventReceiver.java | 15 +++++++++++++++ src/android/JPushPlugin.java | 24 ++++++++++++++++++++++++ www/JPushPlugin.js | 13 ++++++++++--- 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f2f6cde --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +## 6.0.3 (2026-05-14) + +Android 6.1.0新增setKeepLongConnInBackground和onVoipMessage回调;iOS 6.1.0修复已知问题 + +# Changelog + diff --git a/plugin.xml b/plugin.xml index a18838e..0f8d267 100644 --- a/plugin.xml +++ b/plugin.xml @@ -3,7 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" id="jpush-phonegap-plugin" - version="6.0.2"> + version="6.0.3"> JPush JPush for cordova plugin @@ -52,7 +52,7 @@ - + @@ -175,7 +175,7 @@ - + diff --git a/src/android/JPushEventReceiver.java b/src/android/JPushEventReceiver.java index a8d5bf7..2cec29f 100644 --- a/src/android/JPushEventReceiver.java +++ b/src/android/JPushEventReceiver.java @@ -21,6 +21,7 @@ import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushMessage; import cn.jpush.android.api.NotificationMessage; import cn.jpush.android.api.NotificationCustomButton; +import cn.jpush.android.api.VoipDataMessage; import cn.jpush.android.helper.Logger; import cn.jpush.android.local.JPushConstants; import cn.jpush.android.service.JPushMessageReceiver; @@ -245,6 +246,20 @@ public class JPushEventReceiver extends JPushMessageReceiver { } + @Override + public void onVoipMessage(Context context, VoipDataMessage voipDataMessage) { + cn.jiguang.cordova.push.JLogger.d(TAG, "onVoipMessage:" + voipDataMessage); + try { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("messageId", voipDataMessage.getMessageId()); + jsonObject.put("extraData", voipDataMessage.getExtraData()); + jsonObject.put("platform", voipDataMessage.getPlatform()); + cn.jiguang.cordova.push.JPushPlugin.transmitVoipMessage(jsonObject); + } catch (Throwable throwable) { + cn.jiguang.cordova.push.JLogger.d(TAG, "onVoipMessage throwable:" + throwable); + } + } + @Override public void onNotifyButtonClick(Context context, NotificationCustomButton notificationCustomButton) { cn.jiguang.cordova.push.JLogger.d(TAG, "[onNotifyButtonClick], " + notificationCustomButton.toString()); diff --git a/src/android/JPushPlugin.java b/src/android/JPushPlugin.java index 5e1c06e..7e8558b 100644 --- a/src/android/JPushPlugin.java +++ b/src/android/JPushPlugin.java @@ -764,6 +764,30 @@ public class JPushPlugin extends CordovaPlugin { } } + void setBackgroundEnable(JSONArray data, CallbackContext callbackContext) { + try { + boolean keep = data.getBoolean(0); + JPushInterface.setKeepLongConnInBackground(mContext, keep); + callbackContext.success(); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + static void transmitVoipMessage(JSONObject data) { + if (instance == null) { + return; + } + String format = "window.plugins.jPushPlugin.receiveVoipMessageInAndroidCallback(%s);"; + final String js = String.format(format, data.toString()); + cordovaActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + instance.webView.loadUrl("javascript:" + js); + } + }); + } + private boolean isValidHour(int hour) { return !(hour < 0 || hour > 23); } diff --git a/www/JPushPlugin.js b/www/JPushPlugin.js index 80e2c09..370ffc0 100644 --- a/www/JPushPlugin.js +++ b/www/JPushPlugin.js @@ -546,9 +546,16 @@ JPushPlugin.prototype.setAuth = function(isAuth){ * @param isEnable boolean 是否允许长连接 */ JPushPlugin.prototype.setBackgroundEnable = function(isEnable) { - if (this.isPlatformIOS()) { - this.callNative("setBackgroundEnable", [isEnable], null); - } + this.callNative("setBackgroundEnable", [isEnable], null); +}; + +/** + * Android VOIP 消息回调(由 Native 调用,触发 jpush.receiveVoipMessage 事件) + */ +JPushPlugin.prototype.receiveVoipMessageInAndroidCallback = function(data) { + data = JSON.stringify(data); + this.voipMessage = JSON.parse(data); + cordova.fireDocumentEvent("jpush.receiveVoipMessage", this.voipMessage); }; if (!window.plugins) {