AppDelegate.m 3.8 KB

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