Last active
March 30, 2020 09:35
-
-
Save duytq94/343f8f2e06a9f28e535ba60face9f472 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc(TestConnectNativeModule) | |
class TestConnectNativeModule: NSObject { | |
@objc | |
static func requiresMainQueueSetup() -> Bool { | |
return true | |
} | |
@objc | |
func sendMessageToNative(_ rnMessage: String) { | |
print("This log is from swift: \(rnMessage)") | |
} | |
@objc | |
func sendCallbackToNative(_ rnCallback: RCTResponseSenderBlock) { | |
rnCallback(["A greeting from swift"]) | |
} | |
@objc | |
func goToSecondViewController (_ reactTag: NSNumber) { | |
DispatchQueue.main.async { | |
if let view = RNViewManager.sharedInstance.bridge?.uiManager.view(forReactTag: reactTag) { | |
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) | |
let secondVC = storyBoard.instantiateViewController(withIdentifier: "SecondView") as! SencondViewController | |
secondVC.modalPresentationStyle = .fullScreen | |
let reactNativeVC: UIViewController! = view.reactViewController() | |
reactNativeVC.present(secondVC, animated: true, completion: nil) | |
} | |
} | |
} | |
@objc | |
func dismissViewController (_ reactTag: NSNumber) { | |
DispatchQueue.main.async { | |
if let view = RNViewManager.sharedInstance.bridge?.uiManager.view(forReactTag: reactTag) { | |
let reactNativeVC: UIViewController! = view.reactViewController() | |
reactNativeVC.dismiss(animated: true, completion: nil) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment