react-native-splash-screen: Splash screen doesn't disappear

“react-native”: “0.44.0”, “react-native-splash-screen”: “^2.1.0”,

It works fine so far (no updates, nothing new), but splash screen now doesn’t disappear, no error in build. If I remove [Splashscreen show] from the AppDelegate.m file it works, but I want to have some delay. What it could be? It just stopped working, and if I even get back to my previous commits, it still no effect. Could it be problem with my OS or simulator? I don’t yet check on real device.

class AppWithNavigationState extends Component {
  componentDidMount() {
    setTimeout(() => {
      SplashScreen.hide();
    }, 2000)
  }

  render() {
    return (
      <Index
        navigation={addNavigationHelpers({
          dispatch: this.props.dispatch,
          state: this.props.nav
        })}
      />
    )
  }
}

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 5
  • Comments: 41

Most upvoted comments

This is not the first time that I had this issue. So this message it’s for myself in future; To fix on iOS make sure that [RNSplashScreen show]; is the last thing before return YES;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  
  [RNSplashScreen show];
  
  return YES;
}

This is the fix for iOS 😃 thanks @rochapablo

While it’s not recommended to use this lib anymore, now that I upgraded from RN 0.70 to 0.71 using the Upgrade Helper, I inadvertedly broke it in my iOS app (I was unable to hide the splash screen) after applying the patch, because said patch now calls the corresponding method on the superclass. I managed to fix it by changing

  [RNSplashScreen show]; 
  return [super application:application didFinishLaunchingWithOptions:launchOptions];

to

  BOOL ret = [super application:application didFinishLaunchingWithOptions:launchOptions];
  if (ret == YES) {
    [RNSplashScreen show]; 
  }
  return ret;

This makes sure that the method show() is the last thing called, as the docs of the lib recommend.

So, I had the same exact issue, this is how I fixed it. Seems a bit glitchy in my emulator, will test on actual device.

change -> DidMount to -> WillMount

componentWillMount() { SplashScreen.hide(); }

“react”: “^16.3.2”, “react-native”: “^0.55.4”

This is not the first time that I had this issue. So this message it’s for myself in future; To fix on iOS make sure that [RNSplashScreen show]; is the last thing before return YES;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  
  [RNSplashScreen show];
  
  return YES;
}

This is the fix for iOS 😃 thanks @rochapablo

While it’s not recommended to use this lib anymore, now that I upgraded from RN 0.70 to 0.71 using the Upgrade Helper, I inadvertedly broke it in my iOS app (I was unable to hide the splash screen) after applying the patch, because said patch now calls the corresponding method on the superclass. I managed to fix it by changing

  [RNSplashScreen show]; 
  return [super application:application didFinishLaunchingWithOptions:launchOptions];

to

  BOOL ret = [super application:application didFinishLaunchingWithOptions:launchOptions];
  if (ret == YES) {
    [RNSplashScreen show]; 
  }
  return ret;

This makes sure that the method show() is the last thing called, as the docs of the lib recommend.

Thank you very much. I encountered this issue with React Native 0.71.6 and react-native-splash-screen 3.3.0 and have successfully fixed it.

I had this issue too, on iOS only. After debugging, I switched to [RNSplashScreen showSplash: inRootView:] instead of show: and it finally worked.

So my didFinishLaunching code in AppDelegate looks like this instead:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [BugsnagReactNative start];
  NSURL *jsCodeLocation;

  #ifdef DEBUG
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  #else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"MyApp"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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 showSplash:@"LaunchScreen" inRootView:rootViewController.view];
  return YES;
}

This assumes you’re using the LaunchScreen.xib file, not launch images.

This is not the first time that I had this issue. So this message it’s for myself in future;

To fix on iOS make sure that [RNSplashScreen show]; is the last thing before return YES;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  
  [RNSplashScreen show];
  
  return YES;
}

I have the same issue in the release build react-native: 0.56.0 react-native-splash-screen: 3.1.1 and I use the react-navigation library for navigating

android, v3.0.6 with react-native v0.54.4. Sometimes splash screen stays forever, although I explicitly call SplashScreen.hide()

I did the same but then the splashscreen never shows…

This is not the first time that I had this issue. So this message it’s for myself in future;

To fix on iOS make sure that [RNSplashScreen show]; is the last thing before return YES;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  
  [RNSplashScreen show];
  
  return YES;
}

This is the correct fix for iOS

+1 Using “react-native”:“0.47.2” and “react-native-splash-screen”:“^3.0.6”! The screen does not disappear after calling SplashScreen.hide() in componentDidMount() function in my LoginScreen. Here is my AppDelegate.m

#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "SplashScreen.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;
  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"MyApp"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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];
  [SplashScreen show];
  return YES;
}
@end

Here is my LoginScreen.js (as part of StackNavigator of react-navigation):

const AuthNavigator = StackNavigator(
  {
    LoginScreen: {screen: Login},
    RegisterScreen: {screen: Register}
  },
  {
    initialRouteName: 'LoginScreen',
    headerMode: 'none'
  }
)
...
class LoginScreen extends React.Component {
  componentDidMount() {
    setTimeout(SplashScreen.hide(), 3000)
  }
  ...
}

Any help?

Worked for me:

1.Delete (index.android.bundle) files inside directory android/app/src/main/assets.

2.run react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

3.Delete folders (drawable,drawable-hdpi,drawable-mdpi,drawable-xhdpi,drawable-xxhdpi,drawable-xxxhdpi,raw) inside android/app/src/main/res

4.run react-native run-android --variant=release


import android.os.Handler;

@Override protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(MainActivity.this); super.onCreate(savedInstanceState); new Handler().postDelayed(() -> SplashScreen.hide(MainActivity.this), 2500); }

Same. But only when I build release. Any solution?

@wincod75 I’m using the same RN version but in my case, that fix doesn’t seem to work all the time. it was working correctly on iOS, then tried to run it on android, and now it doesn’t work on Android and iOS

Any other fix around?

Environment:
  OS: macOS High Sierra 10.13.3
  Node: 7.9.0
  Yarn: 0.23.2
  npm: 5.8.0
  Watchman: 4.7.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.4 => 0.55.4

UPDATE : My bad, I was initializing the app on a different screen, and I never called SplashScreen.hide();

Did you have a look in #87?

I managed to solve this issue by removing

SplashScreen.show()