diff --git a/ios/RCCManager.h b/ios/RCCManager.h index a3ef0471c6c..7c792a47e4b 100755 --- a/ios/RCCManager.h +++ b/ios/RCCManager.h @@ -13,6 +13,7 @@ -(UIWindow*)getAppWindow; -(void)setAppStyle:(NSDictionary*)appStyle; -(NSDictionary*)getAppStyle; +-(NSDictionary*)getInitialProps; -(void)registerController:(UIViewController*)controller componentId:(NSString*)componentId componentType:(NSString*)componentType; -(id)getControllerWithId:(NSString*)componentId componentType:(NSString*)componentType; diff --git a/ios/RCCManager.m b/ios/RCCManager.m index a7f92f112b9..950a272a3bd 100755 --- a/ios/RCCManager.m +++ b/ios/RCCManager.m @@ -10,6 +10,7 @@ @interface RCCManager() @property (nonatomic, strong) RCTBridge *sharedBridge; @property (nonatomic, strong) NSURL *bundleURL; @property (nonatomic, strong, readwrite) NSDictionary *globalAppStyle; +@property (nonatomic, strong) NSDictionary *launchOptions; @end @implementation RCCManager @@ -46,6 +47,10 @@ - (instancetype)init return self; } +- (NSDictionary *)getInitialProps { + return _launchOptions; +} + -(void)clearModuleRegistry { [self.modulesRegistry removeAllObjects]; @@ -155,6 +160,7 @@ -(void)initBridgeWithBundleURL:(NSURL *)bundleURL launchOptions:(NSDictionary *) { if (self.sharedBridge) return; + self.launchOptions = launchOptions; self.bundleURL = bundleURL; self.sharedBridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; diff --git a/ios/RCCManagerModule.m b/ios/RCCManagerModule.m index b96f24124be..6c9cb2f9fa7 100755 --- a/ios/RCCManagerModule.m +++ b/ios/RCCManagerModule.m @@ -480,4 +480,9 @@ -(BOOL)viewControllerIsModal:(UIViewController*)viewController [RCCManagerModule cancelAllRCCViewControllerReactTouches]; } +RCT_EXPORT_METHOD(getInitialProps:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) +{ + resolve([[RCCManager sharedInstance] getInitialProps]); +} + @end diff --git a/src/Navigation.js b/src/Navigation.js index e543541daf2..c7219b4bd84 100644 --- a/src/Navigation.js +++ b/src/Navigation.js @@ -131,6 +131,10 @@ function dismissInAppNotification(params = {}) { return platformSpecific.dismissInAppNotification(params); } +async function getInitialProps() { + return await platformSpecific.getInitialProps(); +} + async function startTabBasedApp(params) { try { return await platformSpecific.startTabBasedApp(params); @@ -200,5 +204,6 @@ export default { clearEventHandler: clearEventHandler, handleDeepLink: handleDeepLink, isAppLaunched: isAppLaunched, - isRootLaunched: isRootLaunched + isRootLaunched: isRootLaunched, + getInitialProps: getInitialProps }; diff --git a/src/deprecated/controllers/index.js b/src/deprecated/controllers/index.js index 88ffa0e9950..a9ef7cfb2d9 100755 --- a/src/deprecated/controllers/index.js +++ b/src/deprecated/controllers/index.js @@ -128,6 +128,9 @@ var Controllers = { _validateDrawerProps(layout); _processProperties(_.get(layout, 'props.appStyle', {})); return await RCCManager.setRootController(layout, animationType, passProps); + }, + getInitialProps: async function() { + return await RCCManager.getInitialProps(); } }, diff --git a/src/deprecated/platformSpecificDeprecated.ios.js b/src/deprecated/platformSpecificDeprecated.ios.js index 8647af6d707..d0f634a5394 100644 --- a/src/deprecated/platformSpecificDeprecated.ios.js +++ b/src/deprecated/platformSpecificDeprecated.ios.js @@ -586,6 +586,10 @@ function dismissLightBox(params) { Modal.dismissLightBox(); } +async function getInitialProps() { + return await ControllerRegistry.getInitialProps(); +} + function showInAppNotification(params) { if (!params.screen) { console.error('showInAppNotification(params): params.screen is required'); @@ -721,5 +725,6 @@ export default { navigatorToggleNavBar, showContextualMenu, dismissContextualMenu, - getCurrentlyVisibleScreenId + getCurrentlyVisibleScreenId, + getInitialProps };