The RN doco and other examples show how to launch a React-Native view from a native iOS view controller, but not the other way around. Can someone explain how I can do this
There is little improvement on this solution.With present solution there is no way to come back to React-Native from iOS.
If you want to come back again from iOS to React-Native.Do the below
// AppDelegate.h
- (void) goToNativeView {
UIViewController *vc = [InitialViewController new];// This is your native iOS VC
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
dispatch_async(dispatch_get_main_queue(), ^{
// Never do the below, it will be difficult to come back to react-native
// self.window.rootViewController = navigationController;
// Do this instead
[self.window.rootViewController presentViewController:navigationController animated:true completion:NULL];
});
}
//InitialViewController.m
**-Create a button for go back to React-native and on button action dismiss this view controller like below.**
// Dismiss the VC so controll go back from iOS to react-native
[self dismissViewControllerAnimated:TRUE completion:nil];