Skip to content

Commit 81746bc

Browse files
committed
[update]: 适配RN新版本
1 parent cbd56d3 commit 81746bc

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

ios/RCTGetuiModule/RCTGetuiModule/RCTGetuiModule.m

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,68 @@
1313
#import <React/RCTRootView.h>
1414
#import <React/RCTBridge.h>
1515
#import <React/RCTLog.h>
16-
16+
#import <React/RCTEventEmitter.h>
1717
#elif __has_include("RCTBridge.h")
1818
#import "RCTEventDispatcher.h"
1919
#import "RCTRootView.h"
2020
#import "RCTBridge.h"
2121
#import "RCTLog.h"
22+
#import "RCTEventEmitter.h"
2223
#elif __has_include("React/RCTBridge.h")
2324
#import "React/RCTEventDispatcher.h"
2425
#import "React/RCTRootView.h"
2526
#import "React/RCTBridge.h"
2627
#import "React/RCTLog.h"
28+
#import "React/RCTEventEmitter.h"
2729
#endif
2830

2931
#import <PushKit/PushKit.h>
3032

33+
@interface RCTGetuiBridgeTools : RCTEventEmitter
34+
35+
+ (RCTGetuiBridgeTools *)sharedInstance;
36+
37+
@end
38+
39+
@implementation RCTGetuiBridgeTools
40+
41+
RCT_EXPORT_MODULE();
42+
43+
+ (RCTGetuiBridgeTools *)sharedInstance
44+
{
45+
static RCTGetuiBridgeTools * tools = nil;
46+
static dispatch_once_t onceToken;
47+
dispatch_once(&onceToken, ^{
48+
tools = [[RCTGetuiBridgeTools alloc] init];
49+
});
50+
return tools;
51+
}
52+
53+
- (NSArray<NSString *> *)supportedEvents
54+
{
55+
return @[@"GeTuiSdkDidRegisterClient",
56+
@"GeTuiSDkDidNotifySdkState",
57+
@"GeTuiSdkDidOccurError",
58+
@"GetuiSdkGrantAuthorization",
59+
@"GeTuiSdkwillPresentNotification",
60+
@"GeTuiSdkDidReceiveNotification",
61+
@"GeTuiSdkDidReceiveSlience",
62+
@"GeTuiSdkOpenSettingsForNotification",
63+
@"GeTuiSdkDidSendMessage",
64+
@"GeTuiSdkDidSetPushMode",
65+
@"GeTuiSdkDidAlias",
66+
@"GeTuiSdkDidSetTags",
67+
@"GetuiSdkDidQueryTag",
68+
@"voipPushPayload"];
69+
}
70+
71+
- (void)getui_sendAppEventWithName:(NSString *)name body:(id)body {
72+
[self.bridge.eventDispatcher sendAppEventWithName:name body:body];
73+
}
74+
75+
@end
76+
77+
3178
@interface RCTGetuiModuleEvent : NSObject
3279
@property (nonatomic, copy) NSString *name;
3380
@property (nonatomic) id body;
@@ -99,8 +146,7 @@ - (void)getui_sendAppEventWithName:(NSString *)name body:(id)body {
99146
NSLog(@"name:%@ body:%@", name, body);
100147
#endif
101148
if(self.isJsLoad) {
102-
[self.bridge.eventDispatcher sendAppEventWithName:name
103-
body:body];
149+
[[RCTGetuiBridgeTools sharedInstance] getui_sendAppEventWithName:name body:body];
104150
}else {
105151
RCTGetuiModuleEvent *event = [[RCTGetuiModuleEvent alloc] init];
106152
event.name = name;
@@ -207,7 +253,7 @@ - (void)GeTuiSdkDidReceiveSlience:(NSDictionary *)userInfo fromGetui:(BOOL)fromG
207253

208254
- (void)GeTuiSdkNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification {
209255
// [ 参考代码,开发者注意根据实际需求自行修改 ] 根据APP需要自行修改参数值
210-
[self getui_sendAppEventWithName:@"GeTuiSdkOpenSettingsForNotificatio" body:notification.request.content.userInfo];
256+
[self getui_sendAppEventWithName:@"GeTuiSdkOpenSettingsForNotification" body:notification.request.content.userInfo];
211257
}
212258

213259
//MARK: - 发送上行消息

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-getui",
3-
"version": "1.1.41",
3+
"version": "1.1.42",
44
"description": "Getui push sdk plugin for rect-native",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)