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

[v2][ios] Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called #5104

Closed
NdauwaRafael opened this issue May 14, 2019 · 7 comments

Comments

@NdauwaRafael
Copy link

NdauwaRafael commented May 14, 2019

my android works fine but I keep on getting this error on iOS.

Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called.' was thrown while invoking setDefaultOptions on target RNNBridgeModule with params (
        {
        topBar =         {
            backgroundColor = 4294967295;
            elevation = 0;
        };
    }

My AppDelegate.m looks like this

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>
#import <React/RCTRootView.h>
#import "RNSplashScreen.h"
#import <Firebase.h>
//#import "RNFirebaseNotifications.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
 
  [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
  
  
  [FIRApp configure];
//  [RNFirebaseNotifications configure];
  
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
  
  [RNSplashScreen show];
  
  return YES;
}

@end

AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

App.js

import React from 'react';
import {Navigation} from 'react-native-navigation';

import {registerScreens} from './src/navigation/register';

registerScreens(store, Provider);

Navigation.events().registerAppLaunchedListener(() => {
   Navigation.setRoot({
       root: {
           stack: {
               children: [
                   {
                       component: {
                           name: 'App'
                       }
                   }
               ]
           }
       }
   });
});

register.js

import React from 'react';
import {Navigation} from 'react-native-navigation';
import Welcome from '../containers/Auth/Welcome';
import ForgotPassword from '../containers/Auth/ForgotPassword/index';
import LoginMethod from '../containers/Auth/Login/LoginMethod';
import Login from '../containers/Auth/Login';
import Token from '../containers/Auth/Token';
import Generate from '../containers/Auth/Token/Generate';
import MyApp from '../../MyApp';
import Home from '../containers/Home';
import AboutCompany from '../components/common/AboutCompany'


export function registerScreens(store, Provider) {
    //AUTH

    Navigation.registerComponent('AboutCompany', () => (props) => (
        <Provider store={store}>
            <AboutCompany {...props} />
        </Provider>
    ), () => AboutCompany);

    Navigation.registerComponent('Welcome', () => (props) => (
        <Provider store={store}>
            <Welcome {...props} />
        </Provider>
    ), () => Welcome);


    Navigation.registerComponent('ForgotPassword', () => (props) => (
        <Provider store={store}>
            <ForgotPassword {...props} />
        </Provider>
    ), () => ForgotPassword);

    Navigation.registerComponent('LoginMethod', () => (props) => (
        <Provider store={store}>
            <LoginMethod {...props} />
        </Provider>
    ), () => LoginMethod);

    Navigation.registerComponent('Login', () => (props) => (
        <Provider store={store}>
            <Login {...props} />
        </Provider>
    ), () => Login);

    Navigation.registerComponent('Generate', () => (props) => (
        <Provider store={store}>
            <Generate {...props} />
        </Provider>
    ), () => Generate);

    Navigation.registerComponent('Token', () => (props) => (
        <Provider store={store}>
            <Token {...props} />
        </Provider>
    ), () => Token);

    //APP
    Navigation.registerComponent('App', () => (props) => (
        <Provider store={store}>
            <MyApp {...props} />
        </Provider>
    ), () => MyApp);


    //Home
    Navigation.registerComponent('Home', () => (props) => (
        <Provider store={store}>
            <Home {...props} />
        </Provider>
    ), () => Home);
}

Environment

  • React Native Navigation version: ^2.18.2
  • React Native version: ^0.59.7
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Debug XCODE version 10.2

Screenshot

Screenshot 2019-05-14 at 10 42 52

@NdauwaRafael NdauwaRafael changed the title [v2][ios] Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called.' was thrown while invoking setDefaultOptions on target RNNBridgeModule [v2][ios] Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called May 14, 2019
@stale
Copy link

stale bot commented Jun 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

@stale stale bot added the 🏚 stale label Jun 13, 2019
@NdauwaRafael
Copy link
Author

I found the solution, turns out I was passing the default options in the wrong place.

@jsancho
Copy link

jsancho commented Jun 20, 2019

Hi @NdauwaRafael I'm having the same exact issue just now...
App runs fine on Android, iOS simulator and iPhone in debug mode.

However, when I attempt to run on my iPhone in release mode I end up with the Bridge not loaded message.

Could you further explain what was wrong about the way you were passing your options?

@NdauwaRafael
Copy link
Author

NdauwaRafael commented Jun 25, 2019

@jsancho The most likely option is how you are passing the default Options. Make sure you pass them inside.
Navigation.events().registerAppLaunchedListener(() => { // here }

@jsancho
Copy link

jsancho commented Jun 25, 2019

@jsancho The most likely option is how you are passing the default Options. Make sure you pass them inside.
Navigation.events().registerAppLaunchedListener(() => { // here }

Thanks mate, I've triple-checked and that's indeed how I have my configuration.
It's odd, as this only takes place when running in release mode.

I'll see if I can create a simple project with the bare minimum config on which I can reproduce the issue. That might help identify the bug, if there is any.

cheers

@NdauwaRafael
Copy link
Author

Check this out Solution

@jsancho
Copy link

jsancho commented Jun 26, 2019

Check this out Solution

Wow, I was being utterly stupid here.

I had the Navigation.setRoot() and Navigation.setDefaultOptions close together and didn't realise that defaultOptions was out of the first set of brackets.

Formatting it exactly like in the SO answer is what was needed.
Thanks so much for your persistence :)

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

No branches or pull requests

2 participants