AppDelegate.mm 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #import "AppDelegate.h"
  2. #import <React/RCTBundleURLProvider.h>
  3. #import <React/RCTLinkingManager.h>
  4. @implementation AppDelegate
  5. - (BOOL)application:(UIApplication *)application
  6. openURL:(NSURL *)url
  7. options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
  8. {
  9. return [RCTLinkingManager application:application openURL:url options:options];
  10. }
  11. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  12. {
  13. #if DEBUG
  14. #else
  15. NSDictionary *oldSettins = [[NSUserDefaults standardUserDefaults] valueForKey:@"RCTDevMenu"];
  16. if ([oldSettins.allKeys containsObject:@"isDebuggingRemotely"]) {
  17. NSMutableDictionary *settings = oldSettins?[oldSettins mutableCopy]:[NSMutableDictionary dictionary];
  18. [settings removeObjectForKey:@"isDebuggingRemotely"];
  19. [[NSUserDefaults standardUserDefaults] setObject:settings forKey:@"RCTDevMenu"];
  20. }
  21. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"RCT_jsLocation"];
  22. #endif
  23. self.moduleName = @"taroDemo";
  24. // You can add your custom initial props in the dictionary below.
  25. // They will be passed down to the ViewController used by React Native.
  26. self.initialProps = @{};
  27. return [super application:application didFinishLaunchingWithOptions:launchOptions];
  28. }
  29. - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
  30. {
  31. return [self getBundleURL];
  32. }
  33. - (NSURL *)getBundleURL
  34. {
  35. #if DEBUG
  36. return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
  37. #else
  38. return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  39. #endif
  40. }
  41. @end