crazycodeboy / react-native-splash-screen

A splash screen for react-native, hide when application loaded ,it works on iOS and Android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hiding Splashscreen Automatically in IOS.

anshif10 opened this issue · comments

  • What platform does your issue occur on? (IOS)

  • useEffect( () => {
    setTimeout(() => {
    SplashScreen.hide();
    },3000);
    });

  • "react-native-splash-screen": "^3.3.0",

  • rn info


System:
    OS: macOS 12.4
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 24.28 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.0 - /usr/local/bin/node
  Yarn: Not Found
  npm: 8.5.5 - /usr/local/bin/npm
  Watchman: 2022.09.19.00 - /usr/local/bin/watchman
Managers:
  CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
  Android SDK:
    API Levels: 28, 29, 30, 31, 32, 33
    Build Tools: 23.0.1, 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
    System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64, android-Tiramisu | Google APIs Intel x86 Atom_64
    Android NDK: Not Found
IDEs:
  Android Studio: 2021.3 AI-213.7172.25.2113.9123335
  Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
  Java: 11.0.15 - /usr/bin/javac
npmPackages:
  @react-native-community/cli: ^9.2.1 => 9.3.2 
  react: 18.1.0 => 18.1.0 
  react-native: ^0.70.5 => 0.70.6 
  react-native-macos: Not Found
npmGlobalPackages:
  *react-native*: Not Found

Same issue here, Splash Screen did not wait until "hide" function call and its hide automatically. Don't matter in IOS or Android. Any solutions for this issue?

Any update here??

I think you have forgot the native setup.

#import "AppDelegate.h"
#import <Firebase.h>
#import "RNSplashScreen.h"
#import <React/RCTBundleURLProvider.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"TrueCaller";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};
  [FIRApp configure];
  bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions]; // added 
  [RNSplashScreen show];  // here
  return didFinish; // added 
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

One observation I have on the iOS simulator.
If you press "R" on the metro terminal to reload the app, it will autohide without waiting for the SplashScreen.hide() to be called. If you kill the app and relaunch instead of reloading, it will wait for the hide function to be called. Which should be fine given that you can only reload the app in this flow during development.