5.9.0: android 5.9.0 ios:5.9.0

This commit is contained in:
huangshuni
2025-10-21 15:26:48 +08:00
parent e4b4aa1271
commit 43a4917f23
18 changed files with 142 additions and 6 deletions

1
.npmignore Normal file
View File

@@ -0,0 +1 @@
cursor.md

32
cursor.md Normal file
View File

@@ -0,0 +1,32 @@
使用方法修改需求里的内容将需求和步骤内容作为指令让cursor进行执行。
需求:
1. 更新iOS JPush SDK 到 x.x.x 版本, JPush SDK 包的路径是xxx
2. 更新Android JPush SDK 到 x.x.x 版本, JPush SDK 包的路径是xxx
3. 将原生iOS、Android SDK 新增的方法,封装在插件中。
原生SDK新增方法一
iOS:
```
```
Android:
```
```
统一封装为 方法名为 "" 的对外方法。
请按照以下步骤完成:
1. 找到需要升级的iOS JPush SDK替换src/ios/jpush-ios-x.x.x.xcframework 为需要更新的版本。
2. 将plugin.xml中关于jpush-ios-x.x.x.xcframework相关的引用替换为需要更新的版本。
3. 找到需要升级的Android JPush SDK替换src/android/jpush-android-x.x.x.jar 为需要更新的版本。
4. 将plugin.xml中关于jpush-android-x.x.x.jar相关的引用替换为需要更新的版本。
5. 封装新增的方法。(如果没有新增的方法就不用执行这一步)
6. 在plugin.xml中更新插件版本号使用安卓SDK包的版本号。
7. 在package.json中更新插件版本号使用安卓SDK包的版本号。

View File

@@ -586,6 +586,27 @@ document.addEventListener("jpush.receiveMessage", function (event) {
} }
``` ```
## 获取通知点击的参数 (Android only)
### event - jpush.receiveNotifyButtonClick
#### 代码示例
- 在你需要接收通知的的 js 文件中加入:
```js
document.addEventListener("jpush.receiveNotifyButtonClick", function (event) {
if(device.platform == "Android") {
var msgId = event.msgId;
var platform = event.platform;
var name = event.name;
var actionType = event.actionType;
var action = event.action;
var data = event.data;
}
}, false)
```
## 判断系统设置中是否允许当前应用推送 ## 判断系统设置中是否允许当前应用推送
### API - getUserNotificationSettings ### API - getUserNotificationSettings
判断系统设置中是否允许当前应用推送。 判断系统设置中是否允许当前应用推送。

View File

@@ -1,6 +1,6 @@
{ {
"name": "jpush-phonegap-plugin", "name": "jpush-phonegap-plugin",
"version": "5.8.0", "version": "5.9.0",
"description": "JPush for cordova plugin", "description": "JPush for cordova plugin",
"cordova": { "cordova": {
"id": "jpush-phonegap-plugin", "id": "jpush-phonegap-plugin",

View File

@@ -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="5.8.0"> version="5.9.0">
<name>JPush</name> <name>JPush</name>
<description>JPush for cordova plugin</description> <description>JPush for cordova plugin</description>
@@ -48,7 +48,7 @@
<header-file src="src/ios/Plugins/AppDelegate+JPush.h" /> <header-file src="src/ios/Plugins/AppDelegate+JPush.h" />
<source-file src="src/ios/Plugins/AppDelegate+JPush.m" /> <source-file src="src/ios/Plugins/AppDelegate+JPush.m" />
<source-file src="src/ios/lib/jpush-ios-5.7.0.xcframework" framework="true" /> <source-file src="src/ios/lib/jpush-ios-5.9.0.xcframework" framework="true" />
<resource-file src="src/ios/JPushConfig.plist" /> <resource-file src="src/ios/JPushConfig.plist" />
<framework src="CFNetwork.framework" weak="true" /> <framework src="CFNetwork.framework" weak="true" />
@@ -244,7 +244,7 @@
android:writePermission="${applicationId}.permission.JPUSH_MESSAGE" /> android:writePermission="${applicationId}.permission.JPUSH_MESSAGE" />
</config-file> </config-file>
<lib-file src="src/android/libs/jpush-android-5.8.0.jar" /> <lib-file src="src/android/libs/jpush-android-5.9.0.jar" />
<source-file src="src/android/PushService.java" target-dir="src/cn/jiguang/cordova/push" /> <source-file src="src/android/PushService.java" target-dir="src/cn/jiguang/cordova/push" />
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" /> <source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" />

View File

@@ -19,6 +19,7 @@ import cn.jpush.android.api.CustomMessage;
import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.JPushMessage; import cn.jpush.android.api.JPushMessage;
import cn.jpush.android.api.NotificationMessage; import cn.jpush.android.api.NotificationMessage;
import cn.jpush.android.api.NotificationCustomButton;
import cn.jpush.android.helper.Logger; import cn.jpush.android.helper.Logger;
import cn.jpush.android.local.JPushConstants; import cn.jpush.android.local.JPushConstants;
import cn.jpush.android.service.JPushMessageReceiver; import cn.jpush.android.service.JPushMessageReceiver;
@@ -231,6 +232,23 @@ public class JPushEventReceiver extends JPushMessageReceiver {
} }
} }
@Override
public void onNotifyButtonClick(Context context, NotificationCustomButton notificationCustomButton) {
cn.jiguang.cordova.push.JLogger.d(TAG, "[onNotifyButtonClick], " + notificationCustomButton.toString());
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("msgId", notificationCustomButton.a);
jsonObject.put("platform", notificationCustomButton.b);
jsonObject.put("name", notificationCustomButton.c);
jsonObject.put("actionType", notificationCustomButton.d);
jsonObject.put("action", notificationCustomButton.e);
jsonObject.put("data", notificationCustomButton.f);
cn.jiguang.cordova.push.JPushPlugin.transmitNotifyButtonClick(jsonObject);
} catch (Throwable throwable) {
cn.jiguang.cordova.push.JLogger.d(TAG, "[onNotifyButtonClick] throwable:" + throwable);
}
}
interface SuccessCallback{ interface SuccessCallback{
void onSuccessCallback(JSONObject resultJson) throws JSONException; void onSuccessCallback(JSONObject resultJson) throws JSONException;
} }

View File

@@ -197,6 +197,20 @@ public class JPushPlugin extends CordovaPlugin {
} }
}); });
} }
static void transmitNotifyButtonClick( JSONObject data) {
if (instance == null) {
return;
}
String format = "window.plugins.jPushPlugin.receiveNotifyButtonClickCallback(%s);";
final String js = String.format(format, data.toString());
cordovaActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
instance.webView.loadUrl("javascript:" + js);
}
});
}
static void transmitNotificationOpen(JSONObject data) { static void transmitNotificationOpen(JSONObject data) {

View File

@@ -76,10 +76,14 @@ static NSMutableDictionary *_jpushEventCache;
// 设置手机号 // 设置手机号
-(void)setMobileNumber:(CDVInvokedUrlCommand*)command; -(void)setMobileNumber:(CDVInvokedUrlCommand*)command;
// 设置进入后台是否允许长连接 (iOS 5.9.0+)
-(void)setBackgroundEnable:(CDVInvokedUrlCommand*)command;
/* /*
* 以下为js中可监听到的事件 * 以下为js中可监听到的事件
* jpush.openNotification 点击推送消息启动或唤醒app * jpush.openNotification 点击推送消息启动或唤醒app
* jpush.receiveMessage 收到自定义消息 * jpush.receiveMessage 收到自定义消息
* jpush.receiveNotifyButtonClick 收到通知栏自定义按钮点击事件
* jpush.receiveNotification 前台收到推送 * jpush.receiveNotification 前台收到推送
* jpush.backgroundNotification 后台收到推送 * jpush.backgroundNotification 后台收到推送
*/ */

View File

@@ -533,6 +533,12 @@
} }
#pragma mark - (iOS 5.9.0+)
-(void)setBackgroundEnable:(CDVInvokedUrlCommand *)command {
NSNumber* isEnable = [command argumentAtIndex:0];
[JPUSHService setBackgroundEnable:[isEnable boolValue]];
}
#pragma mark - #pragma mark -
+(void)setupJPushSDK:(NSDictionary*)userInfo{ +(void)setupJPushSDK:(NSDictionary*)userInfo{

View File

@@ -9,7 +9,7 @@
* Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved. * Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved.
*/ */
#define JPUSH_VERSION_NUMBER 5.7.0 #define JPUSH_VERSION_NUMBER 5.9.0
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@@ -822,6 +822,16 @@ typedef NS_ENUM(NSUInteger, JPAuthorizationStatus) {
*/ */
+ (void)setPushEnable:(BOOL)isEnable completion:(nullable void (^)(NSInteger iResCode))completion; + (void)setPushEnable:(BOOL)isEnable completion:(nullable void (^)(NSInteger iResCode))completion;
/*!
* @abstract
*
* @param isEnable YES:NO:NO,
*
* @discussion
*
*/
+ (void)setBackgroundEnable:(BOOL)isEnable;
/*! /*!
* @abstract * @abstract
* *

View File

@@ -9,7 +9,7 @@
* Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved. * Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved.
*/ */
#define JPUSH_VERSION_NUMBER 5.7.0 #define JPUSH_VERSION_NUMBER 5.9.0
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@@ -822,6 +822,16 @@ typedef NS_ENUM(NSUInteger, JPAuthorizationStatus) {
*/ */
+ (void)setPushEnable:(BOOL)isEnable completion:(nullable void (^)(NSInteger iResCode))completion; + (void)setPushEnable:(BOOL)isEnable completion:(nullable void (^)(NSInteger iResCode))completion;
/*!
* @abstract
*
* @param isEnable YES:NO:NO,
*
* @discussion
*
*/
+ (void)setBackgroundEnable:(BOOL)isEnable;
/*! /*!
* @abstract * @abstract
* *

View File

@@ -5,6 +5,7 @@ var JPushPlugin = function() {};
JPushPlugin.prototype.receiveMessage = {}; JPushPlugin.prototype.receiveMessage = {};
JPushPlugin.prototype.openNotification = {}; JPushPlugin.prototype.openNotification = {};
JPushPlugin.prototype.receiveNotification = {}; JPushPlugin.prototype.receiveNotification = {};
JPushPlugin.prototype.notifyButtonClick = {};
JPushPlugin.prototype.isPlatformIOS = function() { JPushPlugin.prototype.isPlatformIOS = function() {
return ( return (
@@ -390,6 +391,14 @@ JPushPlugin.prototype.receiveInAppMessageShowCallback = function(data) {
} }
}; };
JPushPlugin.prototype.receiveNotifyButtonClickCallback = function(data) {
if (device.platform === "Android") {
data = JSON.stringify(data);
this.notifyButtonClick = JSON.parse(data);
cordova.fireDocumentEvent("jpush.receiveNotifyButtonClick", this.notifyButtonClick);
}
};
JPushPlugin.prototype.openNotificationInAndroidCallback = function(data) { JPushPlugin.prototype.openNotificationInAndroidCallback = function(data) {
data = JSON.stringify(data); data = JSON.stringify(data);
this.openNotification = JSON.parse(data); this.openNotification = JSON.parse(data);
@@ -523,6 +532,17 @@ JPushPlugin.prototype.setAuth = function(isAuth){
}; };
/**
* 设置进入后台是否允许长连接 (iOS 5.9.0+)
*
* @param isEnable boolean 是否允许长连接
*/
JPushPlugin.prototype.setBackgroundEnable = function(isEnable) {
if (this.isPlatformIOS()) {
this.callNative("setBackgroundEnable", [isEnable], null);
}
};
if (!window.plugins) { if (!window.plugins) {
window.plugins = {}; window.plugins = {};
} }