[React-Native] SplashScreen 관련 이슈

박종준·2024년 2월 14일
0

React Native

목록 보기
8/18

앱을 켰을때 사용자에게 SplashScreen 을 보여주기 위해 패키지를 이용하여 구현하는 과정속에 이슈를 겪었습니다.

SplashScreen 패키지 링크: https://github.com/crazycodeboy/react-native-splash-screen

이슈는 IOS 에서는 스플래시 스크린이 보이는데 메인 스크린으로 이동을 하지 않는 이슈를 보여주고 있습니다.

이슈 링크: https://github.com/crazycodeboy/react-native-splash-screen/issues/71

Github issue에서 확인을 해보니, 저와 비슷한 이슈를 겪는 분들이 다소 있었고 해결 방법이 나와 있었습니다.

이슈 해결 링크: https://github.com/crazycodeboy/react-native-splash-screen/issues/71#issuecomment-1514896853

해결 방법으로는 공식문서에 IOS 플랫폼에서 약간의 코드를 수정할 필요가 있었습니다.

해결 방법으로는 AppDelegate.m 파일에서

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNSplashScreen.h"  // here

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // ...other code

    [RNSplashScreen show];  // here
    // or
    //[RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];
    return YES;
}

@end

윗 코드를 아래 코드처럼 수정을 해주면 됩니다.

  BOOL ret = [super application:application didFinishLaunchingWithOptions:launchOptions];
  if (ret == YES) {
    [RNSplashScreen show]; 
  }
  return ret;
profile
작은 아이디어로 세상을 변화시키고 싶습니다.

0개의 댓글