react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

Splash screen doesn't disappear

Open aleksandr-senichev opened this issue 8 years ago • 42 comments

"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
        })}
      />
    )
  }
}

aleksandr-senichev avatar Jul 22 '17 19:07 aleksandr-senichev

mee too,the error message Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x124c2ecc0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x124a456f0). One of the two will be used. Which one is undefined.

sayhei avatar Aug 01 '17 09:08 sayhei

Out of curiosity, are you using the wix navigator (react-native-navigation)?

emin93 avatar Aug 15 '17 19:08 emin93

@emin93 I just switched to react-native-navigation and it started to bug... Do you have a solution ?

Gp2mv3 avatar Aug 16 '17 11:08 Gp2mv3

Same thing happened to me on Android.

componentWillMount () {
        SplashScreen.show();
    }

    componentDidMount () {
        SplashScreen.hide();
    }

Any solution for this?

hustlerism avatar Aug 17 '17 17:08 hustlerism

same for me on android, and I am using wix navigation

fmoessle avatar Sep 02 '17 19:09 fmoessle

I managed to solve this issue by removing

SplashScreen.show()

hustlerism avatar Sep 04 '17 15:09 hustlerism

I did the same but then the splashscreen never shows...

Gp2mv3 avatar Sep 04 '17 15:09 Gp2mv3

Anyone figured out how to fix it? I have the same problem in Android.

"react-native": "^0.47.0", "react-native-splash-screen": "^3.0.1",

And I'm also using react-native-navigation from wix.

romanglom avatar Sep 24 '17 21:09 romanglom

+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?

ghost avatar Nov 19 '17 23:11 ghost

I am having just exactly the same problem as @ralcon described. Any improvements on this issue? The app is working on Android but on iOS it just stoped at this stage.

6axter82 avatar Nov 24 '17 15:11 6axter82

Any solution?

aditya-simplecrm avatar Dec 18 '17 06:12 aditya-simplecrm

If I add the splash screen through LaunchScreen.xib then this library works like a charm. But if I add splash screen images in Images.xcassets then splash screen is not hiding.

aditya-simplecrm avatar Dec 18 '17 10:12 aditya-simplecrm

Did you have a look in #87?

6axter82 avatar Dec 18 '17 11:12 6axter82

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

cihadturhan avatar Apr 25 '18 19:04 cihadturhan

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"

wincod75 avatar May 18 '18 03:05 wincod75

@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();

facuescobar avatar May 24 '18 19:05 facuescobar

@cihadturhan did you manage to solve it? It happens on my case also from time to time, on Android

oferRounds avatar Jun 19 '18 07:06 oferRounds

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

tandat2209 avatar Jul 02 '18 00:07 tandat2209

I'm using react-navigation and have SwitchNavigator for navigate user base on his/her authentication to the proper page. but unfortunately after first time the app is initialize on release mode the splash screen stuck and never disappear. @wincod75 I think your solution might be closer to my problem but I have to say I've user TabNavigator from react-navigation and when user has auth to access to the tabs then the splash screen does not disappear.

jsina avatar Jul 21 '18 07:07 jsina

Here is what RNN suggested https://medium.com/@pqkluan/how-to-implement-splash-screen-in-react-native-navigation-ee2184a1a96

kevinNejad avatar Aug 19 '18 13:08 kevinNejad

Having the same problem with react-native-navigation (wix). Stuck on splash-screen, and after some time app crashes.

onlaps avatar Aug 27 '18 08:08 onlaps

@onlaps maybe this tutorial could help you How to implement Splash Screen in React Native Navigation

jsina avatar Aug 27 '18 09:08 jsina

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

eddiecooro avatar Nov 19 '18 10:11 eddiecooro

Having the same problem with react-navigation. This only happens in the release build.

nichiyoshi avatar Dec 11 '18 10:12 nichiyoshi

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.

its-artemis-actually avatar Mar 14 '19 19:03 its-artemis-actually

Thanks @its-artemis-actually!!!

thimonwentink avatar Mar 19 '19 07:03 thimonwentink

I had same issue, none of the above solutions worked for me, Then what i simply did was "Cleared Cache" of the temporary app on the emulator and it worked!... now i am afraid it will of-course happen again when that cache comes back!..

SMKH-PRO avatar Mar 26 '19 02:03 SMKH-PRO

Make sure to call SplashScreen.show before the call to super.onCreate, e.g this worked for me:

public class MainActivity extends NavigationActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		SplashScreen.show(this);

		super.onCreate(savedInstanceState);
	}
}

while these resulted in empty white screen after call to SplashScreen.hide:

public class MainActivity extends NavigationActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		SplashScreen.show(this);
	}
}
public class MainActivity extends NavigationActivity {
	@Override
	protected void addDefaultSplashLayout() {
		SplashScreen.show(this);
	}
}

Jyrno42 avatar Mar 28 '19 13:03 Jyrno42

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;
}

rochapablo avatar May 24 '19 17:05 rochapablo

Having the same problem with react-navigation. This only happens in the release build.

I am also facing the same issue as you like in release build splash screen hangs and not moving to next screen. Any solutions ?

kumarutsav111 avatar Jun 13 '19 08:06 kumarutsav111