Skip to content
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

[iOS] Add 1 more solution #234

Merged
merged 4 commits into from
Feb 7, 2019
Merged

Conversation

binhndicts
Copy link
Contributor

Current solution is making didFinishLaunchingWithOptions run longer. Sometime I got crash (only when developing) because of [[NSRunLoop mainRunLoop] runUntilDate:later];.

1 more solution: Add native Splashscreen view to react native rootView and remove when hide(). Users will see Splashscreen while loading and starting JS code like current solution, but it doesn't effect app's lifecycle.

# Conflicts:
#	ios/RNSplashScreen.h
@Jpoliachik
Copy link

This should be the actual iOS implementation. The current implementation of looping on the main thread until hide() is called from JS is pretty hacky and not stable.

@radko93
Copy link
Contributor

radko93 commented Jul 17, 2018

Hey, any usage example?

@binhndicts
Copy link
Contributor Author

@radko93 just modify 1 line in AppDelegate.m

[RNSplashScreen show];
[RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];

where rootView is RCTRootView and LaunchScreen is name of your launch xib file (not support storyboard yet)

@pietro909
Copy link

Is anyone checking this PR? Looks like we need it, too. For sure the way to achieve the splash-screen looks much better than an infinite loop.

Thanks!

@dallen4
Copy link

dallen4 commented Oct 19, 2018

Any idea if there's plans to support .storyboard files implemented for a launch/splash screen?

@zzzeee
Copy link

zzzeee commented Oct 31, 2018

@binhnd-socicom
I put you to submit RNSplashScreen.h and RNSplashScreen. m source copy the two files to my react-native-splash-screen , and unlink, link.
Also the AppDelegate.m file original [RNSplashScreen show] replaced [RNSplashScreen showSplash: @ "LaunchScreen" inRootView: rootView], reRun the is an error.
error: _reactNativeSplashScreen.default.show is not a function


componentDidMount() {
    this.timer2 = setTimeout(() => {
        console.log('SplashScreen show')
        console.log(SplashScreen)
        SplashScreen.show();
    }, 4000);
    this.timer3 = setTimeout(() => {
        console.log('SplashScreen hide')
        SplashScreen.hide();
    }, 6000);
}

componentWillUnmount() {
    clearTimeout(this.timer2);
    clearTimeout(this.timer3);
}

console: >>>>

SplashScreen show
Object {hide: function}
error: _reactNativeSplashScreen.default.show is not a function
error: Unhandled JS Exception: _reactNativeSplashScreen.default.show is not a function

@binhndicts
Copy link
Contributor Author

@zzzeee I think your error doesn't related to my modification as I don't touch to original show() function. Let try to use the origin version first.

@Buzzkill-McSquare
Copy link

I second (third? fourth?) this change. From what we can gather the current implementation blocks FCM notifications, and this one works like a charm.

@creedmangrum
Copy link

Bumping this. Can we get this one in?

@crazycodeboy crazycodeboy merged commit d44ffef into crazycodeboy:master Feb 7, 2019
@mk-nickyang
Copy link

@binhndicts Thanks for the PR mate, really appreciated! Just wondering, is there any solutions for Launch Image?

@binhndicts
Copy link
Contributor Author

@mk-nickyang In my opinion, using launch image is not a good solution as many different resolution devices were released recently. Don't you think using xib or storyboard is more simple and flexible?

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

Successfully merging this pull request may close these issues.

10 participants