Created
August 4, 2022 01:49
-
-
Save topherPedersen/f7d98b01e847c06469248344bfc6d01d to your computer and use it in GitHub Desktop.
Register React Native Navigation External Component in Swift
This file contains hidden or 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
//#import "AppDelegate.h" | |
//#import <React/RCTBridge.h> | |
//#import <React/RCTBundleURLProvider.h> | |
//#import "RNNCustomViewController.h" | |
//#import <ReactNativeNavigation/ReactNativeNavigation.h> | |
class AppDelegate : RCTBridgeDelegate { | |
func application(application:UIApplication!, didFinishLaunchingWithOptions launchOptions:NSDictionary!) -> Bool { | |
self.window = UIWindow(frame:UIScreen.mainScreen().bounds) | |
if #available(iOS 13.0, *) { | |
self.window.backgroundColor = UIColor.systemBackgroundColor() | |
} else { | |
self.window.backgroundColor = UIColor.whiteColor() | |
} | |
self.window.makeKeyWindow() | |
let bridge:RCTBridge! = RCTBridge(delegate:self, launchOptions:launchOptions) | |
ReactNativeNavigation.bootstrapWithBridge(bridge) | |
ReactNativeNavigation.registerExternalComponent("RNNCustomComponent", | |
callback:{ (props:NSDictionary!,bridge:RCTBridge!) in | |
return RNNCustomViewController(props:props) | |
}) | |
return true | |
} | |
// MARK: - RCTBridgeDelegate | |
func sourceURLForBridge(bridge:RCTBridge!) -> NSURL! { | |
#if DEBUG | |
return RCTBundleURLProvider.sharedSettings().jsBundleURLForBundleRoot("index", | |
fallbackResource:nil) | |
#else | |
return NSBundle.mainBundle().URLForResource("main", withExtension:"jsbundle") | |
#endif | |
} | |
func extraModulesForBridge(bridge:RCTBridge!) -> [AnyObject]! { | |
return ReactNativeNavigation.extraModulesForBridge(bridge) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment