React-native-navigation: [v2][ios] Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called

Created on 14 May 2019  路  7Comments  路  Source: wix/react-native-navigation

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

```js

import

@interface AppDelegate : UIResponder

@property (nonatomic, strong) UIWindow *window;

@end

### App.js
 ```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

馃彋 stale

Most helpful comment

@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

All 7 comments

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.

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

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?

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

@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

Check this out Solution

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 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yedidyak picture yedidyak  路  3Comments

EliSadaka picture EliSadaka  路  3Comments

kiroukou picture kiroukou  路  3Comments

viper4595 picture viper4595  路  3Comments

edcs picture edcs  路  3Comments