Skip to content

not working splash screen for react-native 0.71.0 #606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ko-devHong opened this issue Jan 19, 2023 · 41 comments
Open

not working splash screen for react-native 0.71.0 #606

ko-devHong opened this issue Jan 19, 2023 · 41 comments

Comments

@ko-devHong
Copy link

ko-devHong commented Jan 19, 2023

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);
  }
}
@tatiana-lonestone
Copy link

Same here, not working on 0.71 ios

@tatiana-lonestone
Copy link

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

@yahyafahim
Copy link

yahyafahim commented Jan 19, 2023

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

@marcosjoao37
Copy link

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

@Huzaifa1911
Copy link

Huzaifa1911 commented Jan 24, 2023

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.

@gurupatel107
Copy link

@Huzaifa1911 Your solution worked for me. Thanks.

@josmmv
Copy link

josmmv commented Jan 25, 2023

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

@JJalit
Copy link

JJalit commented Jan 27, 2023

@Huzaifa1911 Thank you.. my problem is solved!

@iviveros-code
Copy link

@Huzaifa1911 Works good! Thanks.

@Guilleanto
Copy link

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

@josmmv
Copy link

josmmv commented Feb 22, 2023

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

import android.os.Bundle;

@Guilleanto
Copy link

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

@hungnm11
Copy link

hungnm11 commented Mar 1, 2023

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

@Pattygeek
Copy link

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.

@Yureyny
Copy link

Yureyny commented Mar 10, 2023

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?

@josmmv
Copy link

josmmv commented Mar 10, 2023

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

@Yureyny
Copy link

Yureyny commented Mar 10, 2023

@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
Copy link

Yureyny commented Mar 10, 2023

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

@AFDHAL2009
Copy link

image

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

help please

@Huzaifa1911
Copy link

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

@AFDHAL2009
Copy link

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

@hoseinfo
Copy link

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?

@Adnan-Bacic
Copy link

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.

@muhammadhassan2k3
Copy link

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.

@YvesBoah
Copy link

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

@ashahid-arpatech
Copy link

@Huzaifa1911 works perfectly

@nguyentrancong
Copy link

Many thanhs

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

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

its working with me

@arifbiswas
Copy link

arifbiswas commented Aug 17, 2023

I can't solve this error

@choijiho0021
Copy link

choijiho0021 commented Aug 23, 2023

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!

@DaniMarc
Copy link

I can't solve this error

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

@marioecs
Copy link

marioecs commented May 8, 2024

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import "RNSplashScreen.h" /* 👈🏻 don't forget to import this header */

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"newFrq2";
  // 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 = @{};

  [super application:application didFinishLaunchingWithOptions:launchOptions];
  [RNSplashScreen show]; /* 👈🏻 This solves the problem */
  
  return YES;
}

@WillLennon-Kopis
Copy link

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?

I'm having this same issue. Anyone look into this?

@harshalijain
Copy link

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.

Thank you so much!! I was stuck on this issue for a week!

@coyksdev
Copy link

Same issue in react native 0.75.1

@tauseef112
Copy link

For React-Native version 0.71, in AppDelegate.mm rootView is no longer here. We need access to the rootView.

` - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleName = @"YOUR_PROJECT_NAME";
// 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 = @{};
// return [super application:application didFinishLaunchingWithOptions:launchOptions]; //This will be assigned as success instead

BOOL success = [super application:application didFinishLaunchingWithOptions:launchOptions];

if (success) {
//This is where we will put the logic to get access to rootview
UIView *rootView = self.window.rootViewController.view;

rootView.backgroundColor = [UIColor whiteColor]; // change with your desired backgroundColor

Dynamic *t = [Dynamic new];
UIView *animationUIView = (UIView *)[t createAnimationViewWithRootView:rootView lottieName:@"logo_animated"]; // change lottieName to your lottie files name

// register LottieSplashScreen to RNSplashScreen
[RNSplashScreen showLottieSplash:animationUIView inRootView:rootView];
// casting UIView type to AnimationView type
AnimationView *animationView = (AnimationView *) animationUIView;
// play
[t playWithAnimationView:animationView];
// If you want the animation layout to be forced to remove when hide is called, use this code
[RNSplashScreen setAnimationFinished:true];

}

return success;

}`

@NikhilCodeblaze
Copy link

its stuck on Splash screen @Huzaifa1911

@Huzaifa1911
Copy link

@NikhilCodeblaze, Which version react native you're using?

@NikhilCodeblaze
Copy link

@Huzaifa1911 0.75.4

@hemant-mali-spg
Copy link

hemant-mali-spg commented Dec 5, 2024

UIResponder

Update AppDelegate.h
#import <RCTAppDelegate.h>
#import <UIKit/UIKit.h>

@interface AppDelegate : RCTAppDelegate

@EnD

@hemant-mali-spg
Copy link

hemant-mali-spg commented Dec 5, 2024

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?

I'm having this same issue. Anyone look into this?

UIResponder

Update AppDelegate.h

#import <RCTAppDelegate.h>
#import <UIKit/UIKit.h>

@interface AppDelegate : RCTAppDelegate

@EnD

@ujjwal-jain
Copy link

I am facing same issue on windows platform while using react native version 0.71.7 , can anyone help me what changes i can do to get work on windows platform?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests