title: How to refactor AppDelegate.m to only load app once when using react-native-splash-screen?
body: <p>Seems that on iOS react-native-splash-screen causes the javascript for the application to run twice. This causes issues during the initial load logic of the application. For example, I am unable to detect whether or not the app was opened by a notification since the first load reads the notification then the second load fails to find it.</p>
  <p>I found this Github issue regarding the same problem, but since I'm on a much newer version of React Native, I am not sure how to refactor the loading of the app on iOS to only execute once. <a href="https://github.com/wix/react-native-navigation/issues/5016" rel="nofollow noreferrer">https://github.com/wix/react-native-navigation/issues/5016</a></p>
  <p>The implementation of the splash screen package can be found in this Github <a href="https://github.com/crazycodeboy/react-native-splash-screen/blob/master/ios/RNSplashScreen.m" rel="nofollow noreferrer">https://github.com/crazycodeboy/react-native-splash-screen/blob/master/ios/RNSplashScreen.m</a></p>
  <p>I am really unfamiliar with how the iOS side of things works in React. Any help is appreciated.</p>
  <p>AppDelegate.m</p>
  <pre><code>#import &quot;AppDelegate.h&quot;
  
  #import &lt;React/RCTBridge.h&gt;
  #import &lt;React/RCTBundleURLProvider.h&gt;
  #import &lt;React/RCTRootView.h&gt;
  #import &lt;Firebase.h&gt;
  #import &quot;RNSplashScreen.h&quot;
  #import &lt;GoogleMaps/GoogleMaps.h&gt;
  
  #ifdef FB_SONARKIT_ENABLED
  #import &lt;FlipperKit/FlipperClient.h&gt;
  #import &lt;FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h&gt;
  #import &lt;FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h&gt;
  #import &lt;FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h&gt;
  #import &lt;SKIOSNetworkPlugin/SKIOSNetworkAdapter.h&gt;
  #import &lt;FlipperKitReactPlugin/FlipperKitReactPlugin.h&gt;
  static void InitializeFlipper(UIApplication *application) {
    FlipperClient *client = [FlipperClient sharedClient];
    SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
    [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
    [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
    [client addPlugin:[FlipperKitReactPlugin new]];
    [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
    [client start];
  }
  #endif
  
  @implementation AppDelegate
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
    #ifdef FB_SONARKIT_ENABLED
      InitializeFlipper(application);
    #endif
    [GMSServices provideAPIKey:@&quot;[redacted]&quot;];
    RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
    RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                     moduleName:@&quot;PartyMe&quot;
                                              initialProperties:nil];
    
    if ([FIRApp defaultApp] == nil) {
      [FIRApp configure];
    }
  
    rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    UIViewController *rootViewController = [UIViewController new];
    rootViewController.view = rootView;
    self.window.rootViewController = rootViewController;
    [self.window makeKeyAndVisible];
    [RNSplashScreen show];
    return YES;
  }
  
  - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
  {
  #if DEBUG
    return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@&quot;index&quot; fallbackResource:nil];
  #else
    return [[NSBundle mainBundle] URLForResource:@&quot;main&quot; withExtension:@&quot;jsbundle&quot;];
  #endif
  }
  
  @end
  </code></pre>
  <p><strong>EDIT</strong>
  I tried to update the file by commenting out all of the default React Native loading code. (I know, longshot.) The app loaded the splash screen, but it appears like the app never actually executed - which makes sense.</p>