I have a React Native project which uses react-native-navigation.I have integrated this project with an existing native iOS application in swift.As the documentation of wix says, this line of code will show the react native app through the native iOS app:
let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource: nil)
RCCManager.sharedIntance().initBridge(withBundleURL: jsCodeLocation)
The problem is that by calling this line of code the app opens up the launch screen, whereas I need to open the react native app by pressing a button in native app and push it as a viewController but calling this line of code opens the launch screen again without having any back button to go back to native iOS app. In addition, if I remove this line of code and instead use this below code, then I will get crash. I also tried using this code as the react-native integration documentation mentioned but it doesn't work with react-native-navigation:
let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource: nil)
let bridge = RCTBridge(bundleURL: jsCodeLocation, moduleProvider: nil, launchOptions: nil)
let rootView = RCTRootView(bridge: bridge, moduleName: "MyHotels", initialProperties: nil)
let rnViewController = UIViewController()
rnViewController.view = rootView
self.navigationController?.pushViewController(rnViewController, animated: true)
The above code opens the react native to the way I wish for but it will crash with the error below:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'A bridge instance is required to create an RCTRootView'
my react-native-navigation version is: "^1.1.457"