Open Engraulis61 opened 1 year ago
I don't think it's the same topic.I tried the code block there, but splashscreen.show() didn't work after RNrestart.Restart().
Change the code in your AppDelegate.mm to be
- (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]; // this needs to be called after [super application:application didFinishLaunchingWithOptions:launchOptions];
return didFinish;
}
Thank you for your help, but this solution did not work.
If it's blocking your development, I highly recommend switching to this library https://www.npmjs.com/package/react-native-bootsplash - It's way more maintained and I am planing to move to it as well @Engraulis61
+1 same issue
@a-tokyo Your solution seemed to help in my case thanks! The docs for the package probably should just be updated to reflect this, but the best bet considering this package is largely unmaintained at this point is to move to bootsplash like you suggest.
Change the code in your AppDelegate.mm to be
- (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]; // this needs to be called after [super application:application didFinishLaunchingWithOptions:launchOptions]; return didFinish; }
this solution still causes white flashes at 0.71 there is a proper way to do this, see below
Follow guide from the maintainers https://github.com/facebook/react-native/issues/35937#issuecomment-1617843557
At AppDelegate.mm, override createRootViewWithBridge
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initProps:(NSDictionary *)initProps
{
UIView * view = [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
#if RCT_NEW_ARCH_ENABLED
RCTFabricSurfaceHostingProxyRootView * rootView = (RCTFabricSurfaceHostingProxyRootView *)view;
#else
RCTRootView * rootView = (RCTRootView *)view;
#endif
// workaround:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
UIViewController *vc = [sb instantiateInitialViewController];
rootView.loadingView = vc.view;
return rootView;
}
ive tested in ios 16 and ios 17 seems working fine now
Change the code in your AppDelegate.mm to be
- (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]; // this needs to be called after [super application:application didFinishLaunchingWithOptions:launchOptions]; return didFinish; }
Worked beautifully
What
react-native-splash-screen
version are you using? 3.3.0 What platform does your issue occur on? (Android/iOS/Both) iOS i just want to show user splash screen after rnrestart.restart() command. but Splashscreen.show() method not working on iOS.In older versions of React, I could solve this problem by adding code to the AppDelegate.mm file. However, since the AppDelegate.mm file has changed, I am unable to display the splash screen after using the RNrestart.Restart() command.
I used to use these codes in old versions of React Native:
RCTRootView *rootView = RCTAppSetupDefaultRootView(bridge, @"appname", nil);
UIStoryboard sb = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil]; UIViewController vc = [sb instantiateInitialViewController]; UIView* launchScreenView = vc.view; launchScreenView.frame = self.window.bounds; RCTRootView.loadingView = launchScreenView;
Is there anyone who can help with a solution for this problem?