I am constructing a Native Module in Swift for a RN app the place I “take away” the RN view and cargo a Storyboard, the whole lot works positive however I have to ship a price from RN to this Module however it isn’t being saved, I feel it is as a result of the controller is loaded once more after a name it so the worth is misplaced
It is a simplified model of my code, I name the openMyModule
perform on the RN aspect with the worth and it ought to save the worth on a variable, then it calls a perform on AppDelegate that may open the Storyboard
@objc (MyModule) class MyModule : UIViewController {
@objc static func requiresMainQueueSetup() -> Bool { return true }
var worth = ""
@objc func openMyModule(_ rn_value: String) -> Void {
self.worth = rn_value
DispatchQueue.essential.async {
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
appDelegate.goToNativeView()
}
}
}
}
That is the perform of AppDelegate
- (void) goToNativeView
{
UIViewController *vc = [UIStoryboard storyboardWithName:@"MyModuleScreen" bundle:nil].instantiateInitialViewController;
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
}
I feel that once I name goToNativeView
my controller is loaded once more, that is why the worth is misplaced
So, what I would like is the worth to nonetheless being obtainable on my controller or save the worth on AppDelegate and name it once I want it
There may be any means I can achive this?