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

not working splash screen for react-native 0.71.0

Open ko-devHong opened this issue 3 years ago • 41 comments

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 [email protected]
  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);
  }
}

ko-devHong avatar Jan 19 '23 09:01 ko-devHong

Same here, not working on 0.71 ios

tatiana-lonestone avatar Jan 19 '23 11:01 tatiana-lonestone

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

tatiana-lonestone avatar Jan 19 '23 12:01 tatiana-lonestone

I changed the return to something like this and it worked

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.moduleName = @"Your_App_Name"; [super application:application didFinishLaunchingWithOptions:launchOptions]; [RNSplashScreen show]; // here return YES; }

yahyafahim avatar Jan 19 '23 13:01 yahyafahim

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 :)

marcosjoao37 avatar Jan 19 '23 16:01 marcosjoao37

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.

Huzaifa1911 avatar Jan 24 '23 12:01 Huzaifa1911

@Huzaifa1911 Your solution worked for me. Thanks.

gurupatel107 avatar Jan 24 '23 20:01 gurupatel107

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

josmmv avatar Jan 25 '23 21:01 josmmv

@Huzaifa1911 Thank you.. my problem is solved!

JJalit avatar Jan 27 '23 03:01 JJalit

@Huzaifa1911 Works good! Thanks.

iviveros-code avatar Feb 06 '23 13:02 iviveros-code

i have 0.71.3 and don't work for me image

and in 0.71.3 i have this MainActivity code from RN

image

Guilleanto avatar Feb 22 '23 14:02 Guilleanto

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

import android.os.Bundle;

josmmv avatar Feb 22 '23 15:02 josmmv

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

Guilleanto avatar Feb 22 '23 15:02 Guilleanto

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

hungnm11 avatar Mar 01 '23 05:03 hungnm11

The solution works for me but how can I increase the duration the splash screen shows for? I used setTimeout in useEffect but that didn't work.

Pattygeek avatar Mar 01 '23 10:03 Pattygeek

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?

Yureyny avatar Mar 10 '23 00:03 Yureyny

@Yureyny I have those version too and the solution given by @Huzaifa1911 above worked. Please read the entire issue.

josmmv avatar Mar 10 '23 01:03 josmmv

@Yureyny I have those version too and the solution given by @Huzaifa1911 above worked. Please read the entire issue.

Thank you! I have already solved the problem, only in ios it closes quite quickly, anything to add in this regard?

Yureyny avatar Mar 10 '23 01:03 Yureyny

The solution works for me but how can I increase the duration the splash screen shows for? I used setTimeout in useEffect but that didn't work. You were able to solve your problem since I present the same in IOS

Yureyny avatar Mar 10 '23 01:03 Yureyny

image

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

help please

AFDHAL2009 avatar Mar 24 '23 16:03 AFDHAL2009

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

Huzaifa1911 avatar Mar 24 '23 16:03 Huzaifa1911

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

AFDHAL2009 avatar Mar 26 '23 14:03 AFDHAL2009

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?

hoseinfo avatar Mar 30 '23 13:03 hoseinfo

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.

Adnan-Bacic avatar Apr 05 '23 12:04 Adnan-Bacic

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.

muhammadhassan2k3 avatar Apr 08 '23 11:04 muhammadhassan2k3

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

YvesBoah avatar Apr 27 '23 17:04 YvesBoah

@Huzaifa1911 works perfectly

ashahid-arpatech avatar Jun 15 '23 15:06 ashahid-arpatech

Many thanhs

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

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

its working with me

nguyentrancong avatar Jul 01 '23 06:07 nguyentrancong

I can't solve this error

arifbiswas avatar Aug 17 '23 04:08 arifbiswas

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!

choijiho0021 avatar Aug 23 '23 03:08 choijiho0021

I can't solve this error

Having the same issue on multiple android devices. Did you manage to solve it?

DaniMarc avatar Nov 27 '23 06:11 DaniMarc