HwangTaehyun / react-native-lottie-splash-screen

⚡ Lottie splash screen for your react native app!
MIT License
221 stars 61 forks source link

SplashScreen not loading up. #87

Open dotsinspace opened 11 months ago

dotsinspace commented 11 months ago

react-native info

System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 111.66 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.0.0 - ~/.nvm/versions/node/v18.0.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.6.0 - ~/.nvm/versions/node/v18.0.0/bin/npm
    Watchman: 2023.09.18.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.14.2 - /Users/dotsinspace/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.3 AI-223.8836.35.2231.10811636
    Xcode: 15.0.1/15A507 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.15 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0
    react-native: 0.72.7
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

What react-native-splash-screen version are you using? Version -> 3.3.0 Using it causes error. if i remove it then everything works fine. https://i.imgur.com/8O4KOoP.png

What platform does your issue occur on? (Android/iOS/Both) Right now IOS only. Because i haven't build it on Android yet.

Describe your issue as precisely as possible : 1) When i don't use react-native-splash-screen then every things builds up. but i get black screen nothing loads up. just black screen even bundler doesnt show anything that app is loading etc.

Join a screenshot or video of the problem on the simulator or device? https://i.imgur.com/tcK1mSG.png

Show us the code you are using?

  1. Dynamic.swift
import UIKit
import Foundation
import Lottie

@objc class Dynamic: NSObject {

  @objc func createAnimationView(rootView: UIView, lottieName: String) -> LottieAnimationView {
    let animationView = LottieAnimationView(name: lottieName)
    animationView.frame = rootView.frame
    animationView.center = rootView.center
    animationView.backgroundColor = UIColor.white;
    return animationView;
  }

  @objc func play(animationView: LottieAnimationView) {
    animationView.play(
      completion: { (success) in
        RNSplashScreen.setAnimationFinished(true)
      }
    );
  }
}
  1. startupnews-Bridging-Header.h
//
//  startupnews-Bridging-Header.h
//  startupnews
//
//  Created by dotsinspace on 16/11/23.
//

#ifndef startupnews_Bridging_Header_h
#define startupnews_Bridging_Header_h

#import "RNSplashScreen.h"
#endif /* startupnews_Bridging_Header_h */
  1. AppDelegate.h
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTRootView.h>
#import <React/RCTBundleURLProvider.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>
#import "RNSplashScreen.h"
#import "startupnews-Swift.h"

@implementation AppDelegate

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

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end
  1. AppDelegate.h
#import "RNNAppDelegate.h"
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, strong) NSString *moduleName;
@property (nonatomic, strong) NSDictionary *initialProps;

@end
illlama commented 7 months ago

@dotsinspace Have you find a way to solve this problem?

dotsinspace commented 7 months ago

Yes somewhat working fine.. on limited device....suggesting to quiet this library...move to something else.

  1. Simulator working superbly fine.
  2. Real devices failing.
HwangTaehyun commented 7 months ago

@dotsinspace Could you tell me which device is limited for using this library?

eyupdogan commented 5 months ago

All Simulators/Emulators working fine but some android real devices not working

dotsinspace commented 5 months ago

@HwangTaehyun on IPhone12 it worked fine..and that too on whatever latest release of OS was out there during January.