Created
June 14, 2019 21:39
-
-
Save brentvatne/1ece8c32a3c5c9d0ac3a470460c65603 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
#import <UIKit/UIKit.h> | |
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h> | |
#import <React/RCTBridgeDelegate.h> | |
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate> | |
@property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter; | |
@property (nonatomic, strong) UIWindow *window; | |
@end |
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
#import "AppDelegate.h" | |
#import <React/RCTBundleURLProvider.h> | |
#import <React/RCTRootView.h> | |
#import <UMCore/UMModuleRegistry.h> | |
#import <UMReactNativeAdapter/UMNativeModulesProxy.h> | |
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h> | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]]; | |
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; | |
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"__YOUR_APP_NAME_HERE__" initialProperties:nil]; | |
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; | |
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |
UIViewController *rootViewController = [UIViewController new]; | |
rootViewController.view = rootView; | |
self.window.rootViewController = rootViewController; | |
[self.window makeKeyAndVisible]; | |
return YES; | |
} | |
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge | |
{ | |
NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge]; | |
// You can inject any extra modules that you would like here, more information at: | |
// https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection | |
return extraModules; | |
} | |
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { | |
#ifdef DEBUG | |
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; | |
#else | |
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; | |
#endif | |
} | |
@end |
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
should be
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
// You can inject any extra modules that you would like here, more information at:
// https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
return extraModules;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For other user.
In AppDelegate.h add :
in AppDelegate.m