yogevbd 6 years ago
parent
commit
d86a63cd29

+ 5
- 0
lib/ios/RNNBridgeModule.m View File

@@ -96,5 +96,10 @@ RCT_EXPORT_METHOD(dismissOverlay:(NSString*)commandId componentId:(NSString*)com
96 96
 	}];
97 97
 }
98 98
 
99
+RCT_EXPORT_METHOD(getLaunchArgs:(NSString*)commandId :(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
100
+	NSArray* args = [[NSProcessInfo processInfo] arguments];
101
+	resolve(args);
102
+}
103
+
99 104
 @end
100 105
 

+ 8
- 0
lib/src/Navigation.ts View File

@@ -144,6 +144,14 @@ export class Navigation {
144 144
     return this.commands.dismissOverlay(componentId);
145 145
   }
146 146
 
147
+  /**
148
+   * 
149
+   * Resolves arguments passed on launch
150
+   */
151
+  public getLaunchArgs(): Promise<any> {
152
+    return this.commands.getLaunchArgs();
153
+  }
154
+
147 155
   /**
148 156
    * Obtain the events registry instance
149 157
    */

+ 4
- 0
lib/src/adapters/NativeCommandsSender.ts View File

@@ -57,4 +57,8 @@ export class NativeCommandsSender {
57 57
   dismissOverlay(commandId: string, componentId: string) {
58 58
     return this.nativeCommandsModule.dismissOverlay(commandId, componentId);
59 59
   }
60
+
61
+  getLaunchArgs(commandId: string) {
62
+    return this.nativeCommandsModule.getLaunchArgs(commandId);
63
+  }
60 64
 }

+ 2
- 0
lib/src/commands/Commands.test.ts View File

@@ -437,6 +437,7 @@ describe('Commands', () => {
437 437
         setStackRoot: ['id', {}],
438 438
         showOverlay: [{}],
439 439
         dismissOverlay: ['id'],
440
+        getLaunchArgs: ['id']
440 441
       };
441 442
       const paramsForMethodName = {
442 443
         setRoot: { commandId: 'setRoot+UNIQUE_ID', layout: { root: 'parsed', modals: [], overlays: [] } },
@@ -452,6 +453,7 @@ describe('Commands', () => {
452 453
         setStackRoot: { commandId: 'setStackRoot+UNIQUE_ID', componentId: 'id', layout: 'parsed' },
453 454
         showOverlay: { commandId: 'showOverlay+UNIQUE_ID', layout: 'parsed' },
454 455
         dismissOverlay: { commandId: 'dismissOverlay+UNIQUE_ID', componentId: 'id' },
456
+        getLaunchArgs: { commandId: 'getLaunchArgs+UNIQUE_ID' },
455 457
       };
456 458
       _.forEach(getAllMethodsOfUut(), (m) => {
457 459
         it(`for ${m}`, () => {

+ 7
- 0
lib/src/commands/Commands.ts View File

@@ -139,4 +139,11 @@ export class Commands {
139 139
     this.commandsObserver.notify('dismissOverlay', { commandId, componentId });
140 140
     return result;
141 141
   }
142
+
143
+  public getLaunchArgs() {
144
+    const commandId = this.uniqueIdProvider.generate('getLaunchArgs');
145
+    const result = this.nativeCommandsSender.getLaunchArgs(commandId);
146
+    this.commandsObserver.notify('getLaunchArgs', { commandId });
147
+    return result;
148
+  }
142 149
 }