React Native module for getting launch arguments
npm install react-native-launch-argumentsReact Native module to get launch arguments.
Makes passing parameters from testing libraries and debugs tools to
react-native super easy.
``sh`
npm i react-native-launch-arguments
cd ios && pod install && cd ..
`js`
import { LaunchArguments } from "react-native-launch-arguments";
LaunchArguments.value();
#### Typescript
`ts`
import { LaunchArguments } from "react-native-launch-arguments";
interface MyExpectedArgs {
authToken?: string;
skipAuth?: boolean;
}
LaunchArguments.value
The intended use is with end-to-end tools like Detox.
#### Detox
* See device.launchApp({launchArgs:{...}})
* See launch arguments guide for full details.
#### Appium
* optionalIntentArguments (Android) and processArguments (iOS)
`tsx--ez myBool true --es myStr 'string text'
capabilities: {
optionalIntentArguments: , // Android`
processArguments: {args : ['-myBool', 'true','-myStr', 'string text']}, // iOS
}
#### Maestro
* arguments parameter of launchApp command
`yaml`
- launchApp:
appId: "com.example.app"
arguments:
foo: "This is a string"
isFooEnabled: false
fooValue: 3.24
fooInt: 3
#### XCode
* XCode Launch Args
* In XCode add launch arguments on the "Arguments" tab in the "Run" section of the Scheme editor:
* Product -> Scheme -> Edit Scheme... -> Run -> Arguments tab -> Arguments Passed On Launch
* Set each arg witha preceding -.hello
* For example if you want to set arg to "world" to receive a LaunchArgs instance of{ "hello":"world" }, you would enter the following into the entry space for the arg:`
`
-hello "world"
It takes data from [[NSProcessInfo processInfo] arguments]
#### Verifying install on iPhone simulator
You can use xcrun to boot your app on the simulator.
The following command-line will load your app on the booted iOS simulator. Just
replace com.MyAppBundleId with your Bundle Identifier, and the params with
your params.
`bash`
xcrun simctl launch booted com.MyAppBundleId -noParams -param "hello"
It takes data from currentActivity.getIntent().getBundleExtra("launchArgs") for detox and intent.getExtras() for ADB params
#### Caveats on Android
##### React-Native
Due to React Native issue #37518, on Android, the module force-waits for the Android activity to reach the RESUMED state, before moving foward with native-modules initialization completion. While commonly the wait is scarce (the activity is already in the resumed state at this point), until the RN issue is fixed, the module may introduce delays in app loading time in some edge cases.
##### Expo
There is know expo` bug with empty passed arguments.