|
13 | 13 | #import <React/RCTRootView.h> |
14 | 14 | #import <React/RCTBridge.h> |
15 | 15 | #import <React/RCTLog.h> |
16 | | - |
| 16 | +#import <React/RCTEventEmitter.h> |
17 | 17 | #elif __has_include("RCTBridge.h") |
18 | 18 | #import "RCTEventDispatcher.h" |
19 | 19 | #import "RCTRootView.h" |
20 | 20 | #import "RCTBridge.h" |
21 | 21 | #import "RCTLog.h" |
| 22 | +#import "RCTEventEmitter.h" |
22 | 23 | #elif __has_include("React/RCTBridge.h") |
23 | 24 | #import "React/RCTEventDispatcher.h" |
24 | 25 | #import "React/RCTRootView.h" |
25 | 26 | #import "React/RCTBridge.h" |
26 | 27 | #import "React/RCTLog.h" |
| 28 | +#import "React/RCTEventEmitter.h" |
27 | 29 | #endif |
28 | 30 |
|
29 | 31 | #import <PushKit/PushKit.h> |
30 | 32 |
|
| 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 | + |
31 | 78 | @interface RCTGetuiModuleEvent : NSObject |
32 | 79 | @property (nonatomic, copy) NSString *name; |
33 | 80 | @property (nonatomic) id body; |
@@ -99,8 +146,7 @@ - (void)getui_sendAppEventWithName:(NSString *)name body:(id)body { |
99 | 146 | NSLog(@"name:%@ body:%@", name, body); |
100 | 147 | #endif |
101 | 148 | if(self.isJsLoad) { |
102 | | - [self.bridge.eventDispatcher sendAppEventWithName:name |
103 | | - body:body]; |
| 149 | + [[RCTGetuiBridgeTools sharedInstance] getui_sendAppEventWithName:name body:body]; |
104 | 150 | }else { |
105 | 151 | RCTGetuiModuleEvent *event = [[RCTGetuiModuleEvent alloc] init]; |
106 | 152 | event.name = name; |
@@ -207,7 +253,7 @@ - (void)GeTuiSdkDidReceiveSlience:(NSDictionary *)userInfo fromGetui:(BOOL)fromG |
207 | 253 |
|
208 | 254 | - (void)GeTuiSdkNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification { |
209 | 255 | // [ 参考代码,开发者注意根据实际需求自行修改 ] 根据APP需要自行修改参数值 |
210 | | - [self getui_sendAppEventWithName:@"GeTuiSdkOpenSettingsForNotificatio" body:notification.request.content.userInfo]; |
| 256 | + [self getui_sendAppEventWithName:@"GeTuiSdkOpenSettingsForNotification" body:notification.request.content.userInfo]; |
211 | 257 | } |
212 | 258 |
|
213 | 259 | //MARK: - 发送上行消息 |
|
0 commit comments