crazycodeboy / react-native-splash-screen

A splash screen for react-native, hide when application loaded ,it works on iOS and Android.
MIT License
5.61k stars 1.1k forks source link

Splash screen doesn't disappear #71

Open aleksandr-senichev opened 7 years ago

aleksandr-senichev commented 7 years ago

"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
        })}
      />
    )
  }
}
sayhei commented 7 years ago

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.

emin93 commented 7 years ago

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

Gp2mv3 commented 7 years ago

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

hustlerism commented 7 years ago

Same thing happened to me on Android.

componentWillMount () {
        SplashScreen.show();
    }

    componentDidMount () {
        SplashScreen.hide();
    }

Any solution for this?

fmoessle commented 7 years ago

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

hustlerism commented 7 years ago

I managed to solve this issue by removing

SplashScreen.show()

Gp2mv3 commented 7 years ago

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

romanglom commented 7 years ago

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.

ghost commented 6 years ago

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

6axter82 commented 6 years ago

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.

aditya-simplecrm commented 6 years ago

Any solution?

aditya-simplecrm commented 6 years ago

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.

6axter82 commented 6 years ago

Did you have a look in #87?

cihadturhan commented 6 years ago

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

wincod75 commented 6 years ago

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"

facuescobar commented 6 years ago

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

oferRounds commented 6 years ago

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

tandat2209 commented 6 years ago

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

jsina commented 6 years ago

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.

kevinNejad commented 6 years ago

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

onlaps commented 6 years ago

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

jsina commented 6 years ago

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

eddiecooro commented 5 years ago

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

nichiyoshi commented 5 years ago

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

its-artemis-actually commented 5 years ago

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.

thimonwentink commented 5 years ago

Thanks @its-artemis-actually!!!

SMKH-PRO commented 5 years ago

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!..

Jyrno42 commented 5 years ago

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);
    }
}
rochapablo commented 5 years ago

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;
}
kumarutsav111 commented 5 years ago

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 ?

KristineTrona commented 5 years ago

Same issue here - in debug build it works just fine, but on release stays stuck

eai301 commented 5 years ago

1+

bernhardt1 commented 5 years ago

The issue for me is unpredictable. None of the behavior seems to make sense but here is what I'm seeing ->

I haven't tried a release build yet.

Vahn84 commented 5 years ago

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

ckOfor commented 5 years ago

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

edu1525 commented 4 years ago

In Android I used a Handler to Hide Splash inside native code after 2,5 seconds, so there's no need to hide splash with Javascript. I know this is not the best solution but its working. Inside the onCreate method of the MainActivity put a handler like this:

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

nikhilsmg commented 4 years ago

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

ericrguimaraes commented 1 year ago

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.

ghost commented 1 year ago

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.

davidfarinha commented 1 year ago

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

Thankyou! This worked for me on react-native 0.70+ and react-native-splash-screen 3.2.0.

zahid502 commented 1 year ago

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

to

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

@ericrguimaraes Thank you, it's worked for me. I encountered this issue with: "react-native": "0.72.4" "react-native-splash-screen": "^3.3.0"