Bläddra i källkod

launchArgs format

yogevbd 6 år sedan
förälder
incheckning
a0d9518117

+ 1
- 1
ios/RCCManager.h Visa fil

@@ -13,7 +13,7 @@
13 13
 -(UIWindow*)getAppWindow;
14 14
 -(void)setAppStyle:(NSDictionary*)appStyle;
15 15
 -(NSDictionary*)getAppStyle;
16
--(NSDictionary*)getInitialProps;
16
+-(NSDictionary*)getLaunchArgs;
17 17
 
18 18
 -(void)registerController:(UIViewController*)controller componentId:(NSString*)componentId componentType:(NSString*)componentType;
19 19
 -(id)getControllerWithId:(NSString*)componentId componentType:(NSString*)componentType;

+ 10
- 2
ios/RCCManager.m Visa fil

@@ -46,8 +46,16 @@
46 46
   return self;
47 47
 }
48 48
 
49
-- (NSArray *)getInitialProps {
50
-  return [[NSProcessInfo processInfo] arguments];
49
+- (NSDictionary *)getLaunchArgs {
50
+  NSMutableDictionary* mutableArguments = [[NSMutableDictionary alloc] init];
51
+  NSArray* arguments = [[NSProcessInfo processInfo] arguments];
52
+  for (int i = 0; i < [arguments count]; i+=2) {
53
+    NSString* key = [arguments objectAtIndex:i];
54
+    NSString* value = [arguments objectAtIndex:i+1];
55
+    [mutableArguments setObject:value forKey:key];
56
+  }
57
+  
58
+  return mutableArguments;
51 59
 }
52 60
 
53 61
 -(void)clearModuleRegistry

+ 2
- 2
ios/RCCManagerModule.m Visa fil

@@ -480,9 +480,9 @@ RCT_EXPORT_METHOD(
480 480
     [RCCManagerModule cancelAllRCCViewControllerReactTouches];
481 481
 }
482 482
 
483
-RCT_EXPORT_METHOD(getInitialProps:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
483
+RCT_EXPORT_METHOD(getLaunchArgs:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
484 484
 {
485
-    resolve([[RCCManager sharedInstance] getInitialProps]);
485
+    resolve([[RCCManager sharedInstance] getLaunchArgs]);
486 486
 }
487 487
 
488 488
 @end

+ 2
- 2
src/deprecated/controllers/index.js Visa fil

@@ -129,8 +129,8 @@ var Controllers = {
129 129
       _processProperties(_.get(layout, 'props.appStyle', {}));
130 130
       return await RCCManager.setRootController(layout, animationType, passProps);
131 131
     },
132
-    getInitialProps: async function() {
133
-      return await RCCManager.getInitialProps();
132
+    getLaunchArgs: async function() {
133
+      return await RCCManager.getLaunchArgs();
134 134
     }
135 135
   },
136 136
 

+ 1
- 1
src/deprecated/platformSpecificDeprecated.ios.js Visa fil

@@ -694,7 +694,7 @@ function _saveNavigatorButtonsPassProps(buttons = []) {
694 694
 }
695 695
 
696 696
 async function getLaunchArgs() {
697
-  return await ControllerRegistry.getInitialProps();
697
+  return await ControllerRegistry.getLaunchArgs();
698 698
 }
699 699
 
700 700
 export default {