You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #import "AppDelegate.h"
  2. #import <React/RCTBridge.h>
  3. #import <React/RCTBundleURLProvider.h>
  4. #import <React/RCTRootView.h>
  5. #import <React/RCTLinkingManager.h>
  6. #import <React/RCTConvert.h>
  7. #if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>)
  8. #import <FlipperKit/FlipperClient.h>
  9. #import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
  10. #import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
  11. #import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
  12. #import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
  13. #import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
  14. static void InitializeFlipper(UIApplication *application) {
  15. FlipperClient *client = [FlipperClient sharedClient];
  16. SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
  17. [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
  18. [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
  19. [client addPlugin:[FlipperKitReactPlugin new]];
  20. [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
  21. [client start];
  22. }
  23. #endif
  24. @implementation AppDelegate
  25. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  26. {
  27. #if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>)
  28. InitializeFlipper(application);
  29. #endif
  30. RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  31. RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
  32. id rootViewBackgroundColor = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTRootViewBackgroundColor"];
  33. if (rootViewBackgroundColor != nil) {
  34. rootView.backgroundColor = [RCTConvert UIColor:rootViewBackgroundColor];
  35. } else {
  36. rootView.backgroundColor = [UIColor whiteColor];
  37. }
  38. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  39. UIViewController *rootViewController = [UIViewController new];
  40. rootViewController.view = rootView;
  41. self.window.rootViewController = rootViewController;
  42. [self.window makeKeyAndVisible];
  43. [super application:application didFinishLaunchingWithOptions:launchOptions];
  44. return YES;
  45. }
  46. - (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
  47. {
  48. // If you'd like to export some custom RCTBridgeModules, add them here!
  49. return @[];
  50. }
  51. - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
  52. #ifdef DEBUG
  53. return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  54. #else
  55. return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  56. #endif
  57. }
  58. // Linking API
  59. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  60. return [RCTLinkingManager application:application openURL:url options:options];
  61. }
  62. // Universal Links
  63. - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  64. return [RCTLinkingManager application:application
  65. continueUserActivity:userActivity
  66. restorationHandler:restorationHandler];
  67. }
  68. @end