Skip to content

Commit

Permalink
[update]: 适配RN新版本
Browse files Browse the repository at this point in the history
  • Loading branch information
CLJian committed Feb 16, 2023
1 parent cbd56d3 commit 81746bc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
54 changes: 50 additions & 4 deletions ios/RCTGetuiModule/RCTGetuiModule/RCTGetuiModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,68 @@
#import <React/RCTRootView.h>
#import <React/RCTBridge.h>
#import <React/RCTLog.h>

#import <React/RCTEventEmitter.h>
#elif __has_include("RCTBridge.h")
#import "RCTEventDispatcher.h"
#import "RCTRootView.h"
#import "RCTBridge.h"
#import "RCTLog.h"
#import "RCTEventEmitter.h"
#elif __has_include("React/RCTBridge.h")
#import "React/RCTEventDispatcher.h"
#import "React/RCTRootView.h"
#import "React/RCTBridge.h"
#import "React/RCTLog.h"
#import "React/RCTEventEmitter.h"
#endif

#import <PushKit/PushKit.h>

@interface RCTGetuiBridgeTools : RCTEventEmitter

+ (RCTGetuiBridgeTools *)sharedInstance;

@end

@implementation RCTGetuiBridgeTools

RCT_EXPORT_MODULE();

+ (RCTGetuiBridgeTools *)sharedInstance
{
static RCTGetuiBridgeTools * tools = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
tools = [[RCTGetuiBridgeTools alloc] init];
});
return tools;
}

- (NSArray<NSString *> *)supportedEvents
{
return @[@"GeTuiSdkDidRegisterClient",
@"GeTuiSDkDidNotifySdkState",
@"GeTuiSdkDidOccurError",
@"GetuiSdkGrantAuthorization",
@"GeTuiSdkwillPresentNotification",
@"GeTuiSdkDidReceiveNotification",
@"GeTuiSdkDidReceiveSlience",
@"GeTuiSdkOpenSettingsForNotification",
@"GeTuiSdkDidSendMessage",
@"GeTuiSdkDidSetPushMode",
@"GeTuiSdkDidAlias",
@"GeTuiSdkDidSetTags",
@"GetuiSdkDidQueryTag",
@"voipPushPayload"];
}

- (void)getui_sendAppEventWithName:(NSString *)name body:(id)body {
[self.bridge.eventDispatcher sendAppEventWithName:name body:body];
}

@end


@interface RCTGetuiModuleEvent : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic) id body;
Expand Down Expand Up @@ -99,8 +146,7 @@ - (void)getui_sendAppEventWithName:(NSString *)name body:(id)body {
NSLog(@"name:%@ body:%@", name, body);
#endif
if(self.isJsLoad) {
[self.bridge.eventDispatcher sendAppEventWithName:name
body:body];
[[RCTGetuiBridgeTools sharedInstance] getui_sendAppEventWithName:name body:body];
}else {
RCTGetuiModuleEvent *event = [[RCTGetuiModuleEvent alloc] init];
event.name = name;
Expand Down Expand Up @@ -207,7 +253,7 @@ - (void)GeTuiSdkDidReceiveSlience:(NSDictionary *)userInfo fromGetui:(BOOL)fromG

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

//MARK: - 发送上行消息
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-getui",
"version": "1.1.41",
"version": "1.1.42",
"description": "Getui push sdk plugin for rect-native",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 81746bc

Please sign in to comment.