|
| 1 | +#import "AppDelegate.h" |
| 2 | + |
| 3 | +#import <React/RCTBundleURLProvider.h> |
| 4 | +#import <React/RCTLinkingManager.h> |
| 5 | + |
| 6 | +@implementation AppDelegate |
| 7 | + |
| 8 | +- (void)applicationDidFinishLaunching:(NSNotification *)notification |
| 9 | +{ |
| 10 | + self.moduleName = @"Example"; |
| 11 | + // You can add your custom initial props in the dictionary below. |
| 12 | + // They will be passed down to the ViewController used by React Native. |
| 13 | + self.initialProps = @{}; |
| 14 | + |
| 15 | + return [super applicationDidFinishLaunching:notification]; |
| 16 | +} |
| 17 | + |
| 18 | +- (void)applicationWillFinishLaunching:(NSNotification *)notification { |
| 19 | + [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self |
| 20 | + andSelector:@selector(getURL:withReplyEvent:) |
| 21 | + forEventClass:kInternetEventClass |
| 22 | + andEventID:kAEGetURL]; |
| 23 | +} |
| 24 | + |
| 25 | +- (void)getURL:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)reply |
| 26 | +{ |
| 27 | + NSString* urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; |
| 28 | + NSURL *url = [NSURL URLWithString:urlString]; |
| 29 | + |
| 30 | + if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) { |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + [RCTLinkingManager getUrlEventHandler:event withReplyEvent:reply]; |
| 35 | +} |
| 36 | + |
| 37 | +- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge |
| 38 | +{ |
| 39 | +#if DEBUG |
| 40 | + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; |
| 41 | +#else |
| 42 | + return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; |
| 43 | +#endif |
| 44 | +} |
| 45 | + |
| 46 | +/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off. |
| 47 | +/// |
| 48 | +/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html |
| 49 | +/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). |
| 50 | +/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`. |
| 51 | +- (BOOL)concurrentRootEnabled |
| 52 | +{ |
| 53 | +#ifdef RN_FABRIC_ENABLED |
| 54 | + return true; |
| 55 | +#else |
| 56 | + return false; |
| 57 | +#endif |
| 58 | +} |
| 59 | + |
| 60 | +@end |
0 commit comments