diff --git a/ios/RCTGetuiModule/RCTGetuiModule/RCTGetuiModule.m b/ios/RCTGetuiModule/RCTGetuiModule/RCTGetuiModule.m index 118c9a5..f1c5a7a 100755 --- a/ios/RCTGetuiModule/RCTGetuiModule/RCTGetuiModule.m +++ b/ios/RCTGetuiModule/RCTGetuiModule/RCTGetuiModule.m @@ -13,21 +13,68 @@ #import #import #import - +#import #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 +@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 *)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; @@ -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; @@ -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: - 发送上行消息 diff --git a/package-lock.json b/package-lock.json index 49f257d..eb39c79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "react-native-getui", - "version": "1.1.41", + "version": "1.1.42", "lockfileVersion": 1 } diff --git a/package.json b/package.json index 23b9641..e4e1a8c 100644 --- a/package.json +++ b/package.json @@ -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": {