Skip to content

Commit 8d00e18

Browse files
committed
3.2.1:android 5.9.0 ios 5.9.0
1 parent 376651e commit 8d00e18

File tree

19 files changed

+148
-12
lines changed

19 files changed

+148
-12
lines changed
Binary file not shown.

android/src/main/java/cn/jiguang/plugins/push/common/JConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class JConstants {
6666
public static final String LOCAL_NOTIFICATION_EVENT = "LocalNotificationEvent";
6767
public static final String TAG_ALIAS_EVENT = "TagAliasEvent";
6868
public static final String MOBILE_NUMBER_EVENT = "MobileNumberEvent";
69+
public static final String NOTIFY_BUTTON_CLICK_EVENT = "NotifyButtonClickEvent";
6970
public static final String COMMAND_EVENT = "CommandEvent";
7071
public static final String BADGE_NUMBER = "badge";
7172
public static final String PROPERTIES = "pros";

android/src/main/java/cn/jiguang/plugins/push/helper/JPushHelper.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import cn.jpush.android.api.CustomMessage;
2222
import cn.jpush.android.api.JPushMessage;
2323
import cn.jpush.android.api.NotificationMessage;
24+
import cn.jpush.android.api.NotificationCustomButton;
2425

2526
public class JPushHelper {
2627

@@ -72,6 +73,22 @@ public static WritableMap convertCustomMessage(CustomMessage customMessage) {
7273
return writableMap;
7374
}
7475

76+
public static WritableMap convertNotificationCustomButtonToMap(NotificationCustomButton notificationCustomButton) {
77+
WritableMap writableMap = Arguments.createMap();
78+
try {
79+
writableMap.putString("msgId", notificationCustomButton.a);
80+
writableMap.putInt("platform", notificationCustomButton.b);
81+
writableMap.putString("name", notificationCustomButton.c);
82+
writableMap.putInt("actionType", notificationCustomButton.d);
83+
writableMap.putString("action", notificationCustomButton.e);
84+
writableMap.putString("data", notificationCustomButton.f);
85+
return writableMap;
86+
} catch (Throwable throwable) {
87+
JLogger.w("convertNotificationCustomButtonToMap error:" + throwable.getMessage());
88+
return writableMap;
89+
}
90+
}
91+
7592
public static WritableMap convertJPushMessageToMap(int type, JPushMessage message) {
7693
WritableMap writableMap = Arguments.createMap();
7794

android/src/main/java/cn/jiguang/plugins/push/receiver/JPushModuleReceiver.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import cn.jpush.android.api.JPushMessage;
1515
import cn.jpush.android.api.NotificationMessage;
1616
import cn.jpush.android.service.JPushMessageReceiver;
17+
import cn.jpush.android.api.NotificationCustomButton;
1718

1819
public class JPushModuleReceiver extends JPushMessageReceiver {
1920

@@ -81,6 +82,13 @@ public void onNotifyMessageDismiss(Context context, NotificationMessage notifica
8182
JPushHelper.sendEvent(JConstants.NOTIFICATION_EVENT, writableMap);
8283
}
8384

85+
@Override
86+
public void onNotifyButtonClick(Context context, NotificationCustomButton notificationCustomButton) {
87+
JLogger.d("onNotifyButtonClick:" + notificationCustomButton.toString());
88+
WritableMap writableMap = JPushHelper.convertNotificationCustomButtonToMap(notificationCustomButton);
89+
JPushHelper.sendEvent(JConstants.NOTIFY_BUTTON_CLICK_EVENT, writableMap);
90+
}
91+
8492
@Override
8593
public void onRegister(Context context, String registrationId) {
8694
JLogger.d("onRegister:" + registrationId);

cursor.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
请按照以下步骤完成:
2424

2525
1. 找到需要升级的iOS JPush SDK,替换ios/RCTJPushModule/jpush-ios-x.x.x.xcframework 为需要更新的版本。
26-
2. 找到需要升级的Android JPush SDK,替换android/libs/jpush-android-x.x.x.jar 为需要更新的版本。
27-
3. 在插件中封装需求中需要封装的SDK方法,并在插件示例demo中提供示例调用代码,注意rn插件新增方法还需要再index.js和index.d.ts文件中声明哦。(如果没有需求中没有需要新增的方法,则跳过该步骤)
28-
4. 在package.json中更新插件版本号,在现有版本号上 + 0.0.1
29-
5. 在example/package.json 中 修改示例 插件的集成版本号。 改为最新的插件版本号。涉及到更改的代码
26+
2. 将/ios/RCTJPushModule.xcodeproj/project.pbxproj中关于jpush-ios-x.x.x.xcframework中引用路径的代码,替换为需要更新的版本。
27+
3. 找到需要升级的Android JPush SDK,替换android/libs/jpush-android-x.x.x.jar 为需要更新的版本。
28+
4. 在插件中封装需求中需要封装的SDK方法,并在插件示例demo中提供示例调用代码,注意rn插件新增方法还需要再index.js和index.d.ts文件中声明哦。(如果没有需求中没有需要新增的方法,则跳过该步骤)
29+
5. 在package.json中更新插件版本号,在现有版本号上 + 0.0.1
30+
6. 在example/package.json 中 修改示例 插件的集成版本号。 改为最新的插件版本号。涉及到更改的代码
3031

3132
```
3233
"dependencies": {

example/App.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default class App extends React.Component {
5252
}
5353

5454
componentDidMount() {
55+
// JPush.setBackgroundEnable(true);
5556
JPush.init({"appKey":"4fcc3e237eec4c4fb804ad49","channel":"dev","production":1});
5657
//连接状态
5758
this.connectListener = result => {
@@ -74,6 +75,11 @@ export default class App extends React.Component {
7475
console.log("customMessageListener:" + JSON.stringify(result))
7576
};
7677
JPush.addCustomMessageListener(this.customMessageListener);
78+
//通知按钮点击回调
79+
this.notifyButtonClickListener = result => {
80+
console.log("notifyButtonClickListener:" + JSON.stringify(result))
81+
};
82+
JPush.addNotifyButtonClickListener(this.notifyButtonClickListener);
7783
//应用内消息回调
7884
JPush.pageEnterTo("HomePage") // 进入首页,当页面退出时请调用 JPush.pageLeave('HomePage')
7985
this.inappMessageListener = result => {

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"jcore-react-native": "^2.3.0",
14-
"jpush-react-native": "^3.1.9",
14+
"jpush-react-native": "^3.2.1",
1515
"react": "18.2.0",
1616
"react-native": "0.74.1"
1717
},

index.d.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,36 @@ export default class JPush {
315315
}>
316316
): void;
317317

318+
// 通知按钮点击事件, Android Only
319+
static addNotifyButtonClickListener(
320+
callback: Callback<{
321+
/**
322+
* 唯一标识通知按钮点击的 ID
323+
*/
324+
msgId: string;
325+
/**
326+
* 平台
327+
*/
328+
platform: number;
329+
/**
330+
* 按钮名称
331+
*/
332+
name: string;
333+
/**
334+
* 按钮动作类型
335+
*/
336+
actionType: number;
337+
/**
338+
* 按钮动作
339+
*/
340+
action: string;
341+
/**
342+
* 按钮数据
343+
*/
344+
data: string;
345+
}>
346+
): void;
347+
318348
/**
319349
* inapp消息事件
320350
*/
@@ -547,4 +577,13 @@ export default class JPush {
547577
wifi: boolean;
548578
}): void;
549579

580+
/**
581+
* 设置进入后台是否允许长连接
582+
* 支持版本:v5.9.0 版本开始
583+
* 功能说明:设置进入后台是否允许长连接。默认是NO,进入后台会关闭长连接,回到前台会重新接入。请在初始化函数之前调用。
584+
*
585+
* @platform iOS
586+
*/
587+
static setBackgroundEnable(enable: boolean): void;
588+
550589
}

index.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const ConnectEvent = 'ConnectEvent' //连接状态
1111
const NotificationEvent = 'NotificationEvent' //通知事件
1212
const LocalNotificationEvent = 'LocalNotificationEvent' //本地通知事件
1313
const CustomMessageEvent = 'CustomMessageEvent' //自定义消息事件
14+
const NotifyButtonClickEvent = 'NotifyButtonClickEvent' //通知按钮点击事件
1415
const InappMessageEvent = 'InappMessageEvent' //应用内消息事件
1516
const TagAliasEvent = 'TagAliasEvent' //TagAlias/Pros事件
1617
const MobileNumberEvent = 'MobileNumberEvent' //电话号码事件
@@ -515,6 +516,31 @@ export default class JPush {
515516
})
516517
}
517518

519+
/*
520+
* 通知按钮点击事件, Android Only
521+
*
522+
* @param {Function} callback = (result) => {"msgId":String,"platform":number, "name":string, "actionType":number, "action":string, "data":string}}}
523+
*
524+
* msgId:唯一标识通知按钮点击的 ID
525+
*
526+
* platform:平台
527+
*
528+
* name:按钮名称
529+
*
530+
* actionType:按钮动作类型
531+
*
532+
* action:按钮动作
533+
*
534+
* data:按钮数据
535+
*
536+
* */
537+
static addNotifyButtonClickListener(callback) {
538+
listeners[callback] = DeviceEventEmitter.addListener(
539+
NotifyButtonClickEvent, result => {
540+
callback(result)
541+
})
542+
}
543+
518544
/*
519545
* 应用内消息事件
520546
*
@@ -752,4 +778,17 @@ export default class JPush {
752778
}
753779
}
754780

781+
/*
782+
* 设置进入后台是否允许长连接
783+
* 支持版本:v5.9.0 版本开始
784+
* 功能说明:设置进入后台是否允许长连接。默认是NO,进入后台会关闭长连接,回到前台会重新接入。请在初始化函数之前调用。
785+
* @param enable = boolean
786+
* @platform iOS
787+
* */
788+
static setBackgroundEnable(enable) {
789+
if (Platform.OS == "ios") {
790+
JPushModule.setBackgroundEnable(enable)
791+
}
792+
}
793+
755794
}

ios/RCTJPushModule.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
5C103CA7236041E7000AD3DA /* RCTJPushEventQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C103CA6236041E7000AD3DA /* RCTJPushEventQueue.m */; };
1111
624386D81E096B8800F69E07 /* RCTJPushModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 624386D41E096B8800F69E07 /* RCTJPushModule.m */; };
12-
A40EE5272E2F693E00FD1C66 /* jpush-ios-5.7.0.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A40EE5262E2F693E00FD1C66 /* jpush-ios-5.7.0.xcframework */; };
12+
A40EE5272E2F693E00FD1C66 /* jpush-ios-5.9.0.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A40EE5262E2F693E00FD1C66 /* jpush-ios-5.9.0.xcframework */; };
1313
/* End PBXBuildFile section */
1414

1515
/* Begin PBXCopyFilesBuildPhase section */
@@ -30,15 +30,15 @@
3030
624386D31E096B8800F69E07 /* RCTJPushModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTJPushModule.h; sourceTree = "<group>"; };
3131
624386D41E096B8800F69E07 /* RCTJPushModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTJPushModule.m; sourceTree = "<group>"; };
3232
6280980A1CEDC407000D3A81 /* libRCTJPushModule.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTJPushModule.a; sourceTree = BUILT_PRODUCTS_DIR; };
33-
A40EE5262E2F693E00FD1C66 /* jpush-ios-5.7.0.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = "jpush-ios-5.7.0.xcframework"; path = "RCTJPushModule/jpush-ios-5.7.0.xcframework"; sourceTree = "<group>"; };
33+
A40EE5262E2F693E00FD1C66 /* jpush-ios-5.9.0.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = "jpush-ios-5.9.0.xcframework"; path = "RCTJPushModule/jpush-ios-5.9.0.xcframework"; sourceTree = "<group>"; };
3434
/* End PBXFileReference section */
3535

3636
/* Begin PBXFrameworksBuildPhase section */
3737
628098071CEDC407000D3A81 /* Frameworks */ = {
3838
isa = PBXFrameworksBuildPhase;
3939
buildActionMask = 2147483647;
4040
files = (
41-
A40EE5272E2F693E00FD1C66 /* jpush-ios-5.7.0.xcframework in Frameworks */,
41+
A40EE5272E2F693E00FD1C66 /* jpush-ios-5.9.0.xcframework in Frameworks */,
4242
);
4343
runOnlyForDeploymentPostprocessing = 0;
4444
};
@@ -48,7 +48,7 @@
4848
5CF8E647231E3A9200B12200 /* Frameworks */ = {
4949
isa = PBXGroup;
5050
children = (
51-
A40EE5262E2F693E00FD1C66 /* jpush-ios-5.7.0.xcframework */,
51+
A40EE5262E2F693E00FD1C66 /* jpush-ios-5.9.0.xcframework */,
5252
);
5353
name = Frameworks;
5454
sourceTree = "<group>";

0 commit comments

Comments
 (0)