react-native-splash-screen: not working splash screen for react-native 0.71.0

Run react-native info in your project and share the content.

What react-native-splash-screen version are you using? 3.3.0

What platform does your issue occur on? Both

Describe your issue as precisely as possible :

  1. install react-native-splash-screen@3.3.0
  2. setting native
  3. doesn’t start splash screen

ref : ios Splash screen

[RNSplashScreen show]; // After this line, no further process will proceed.

Join a screenshot or video of the problem on the simulator or device? 스크린샷 2023-01-19 오후 5 55 11

Show us the code you are using?

  • ios
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"ttttapp";
  
 [RNSplashScreen show];

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
  • android
public class MainActivity extends ReactActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    androidx.core.splashscreen.SplashScreen.installSplashScreen(this);
    org.devio.rn.splashscreen.SplashScreen.show(this, true);
    super.onCreate(savedInstanceState);
  }
}

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 20
  • Comments: 30

Most upvoted comments

You can show splash screen like below code snippet. It works fines for the latest React Native Version (0.71.1).

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{  
  self.moduleName = @"ProjectName";
  // 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 = @{};
  
  bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions];
  
  [RNSplashScreen show];  // here
  return didFinish;
}

Reason why this happens: Your Splash Screen should shown after the IOS finishes the launch. In your case, you’re showing the Splash Screen before finishing the launch options. RNSplash doesn’t know where to get attach before the rootView setup.

Hope you will find this solution insightful.

I think thi is just a problem with the documentation. I tried this for ios and it works :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"reactApp";
  
  [super application:application didFinishLaunchingWithOptions:launchOptions];
  [RNSplashScreen show];

  return YES;
}

It works on android with :

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this);
    super.onCreate(savedInstanceState);
  }

@Guilleanto you have to add the following line at the top of the MainActivity.java file:

import android.os.Bundle;

@Huzaifa1911 Your solution worked for me. Thanks.

when I put this line [super application:application didFinishLaunchingWithOptions:launchOptions]; to app delegate I got this issue: No visible @interface for ‘UIResponder’ declares the selector ‘application:didFinishLaunchingWithOptions:’

any solution?

//Add public class MainActivity extends ReactActivity { @Override protected void onCreate(Bundle savedInstanceState) { androidx.core.splashscreen.SplashScreen.installSplashScreen(this); org.devio.rn.splashscreen.SplashScreen.show(this, true); super.onCreate(savedInstanceState); } }

@AFDHAL2009 I think you didn’t import the libraries correctly. In MainApplication.java, you need to add below line. import org.devio.rn.splashscreen.SplashScreenReactPackage;

In MainActivity.java, you need to add below line. import org.devio.rn.splashscreen.SplashScreen;

You can show splash screen like below code snippet. It works fines for the latest React Native Version (0.71.1).

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{  
  self.moduleName = @"ProjectName";
  // 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 = @{};
  
  bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions];
  
  [RNSplashScreen show];  // here
  return didFinish;
}

Reason why this happens: Your Splash Screen should shown after the IOS finishes the launch. In your case, you’re showing the Splash Screen before finishing the launch options. RNSplash doesn’t know where to get attach before the rootView setup.

Hope you will find this solution insightful.

I spent almost a day on this issue.

I read this now I solve it. Thank you!

@Huzaifa1911 thanks I try to add with the correct import the app launch but crash happen ,so i replace this by null SplashScreen.show(null); save my life it works fine .

I was trying to fix this for over 1 day, thanks @Huzaifa1911

@Huzaifa1911 Thanks man! I was trying to fix this for 6 hours, you saved me. 🥳

Many thanhs

"  self.initialProps = @{};
  
  bool didFinish=[super application:application didFinishLaunchingWithOptions:launchOptions];

  // splash screen
  [RNSplashScreen show];
  return didFinish;
}"

its working with me

@Huzaifa1911 works perfectly

I think thi is just a problem with the documentation.

i dont necessarily think its the documentation. the Appdelegate.mm file was changed a lot in react-native 0.71. see here: https://react-native-community.github.io/upgrade-helper/?from=0.70.8&to=0.71.0

didFinishLaunchingWithOptions used to return YES;. then it was changed to return [super application:application didFinishLaunchingWithOptions:launchOptions];

it seems the fix you posted still has return YES;

im sure there is a reason the react-native team changed the return statement. either way it seems we have to change it back to get the splash screen to work again.

image

I have same issue in react native : “react-native”: “0.70.6”, image

help please

ave 0.71.3 and don’t work for me

I have the same problem using reactNative “react-native”: “0.71.3”, and “react-native-splash-screen”: “^3.3.0”.

Has anyone been able to solve this using these versions?

@Guilleanto you have to add the following line at the top of the MainActivity.java file:

import android.os.Bundle;

Works! thank you so much… solved!

@Huzaifa1911 Works good! Thanks.

@Huzaifa1911 Thank you… my problem is solved!

I think thi is just a problem with the documentation. I tried this for ios and it works :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"reactApp";
  
  [super application:application didFinishLaunchingWithOptions:launchOptions];
  [RNSplashScreen show];

  return YES;
}

It works on android with :

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this);
    super.onCreate(savedInstanceState);
  }

Thank you for that feedback! It worked here 😃