maestro icon indicating copy to clipboard operation
maestro copied to clipboard

React Native boolean launch arguments

Open christinachimi opened this issue 1 year ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and didn't find mine.

Steps to reproduce

Create a test file with a boolean launch argument:

appId: com.myapp.development
---
- launchApp:
    appId: com.flyzipline.partner.portalapp.development
    arguments:
      isFoo: true
- assertTrue: true

In my app code, I use react-native-launch-arguments to get the value, something like:

LaunchArguments.value().isFoo === true

Actual results

The argument seems to be undefined in my app code.

Expected results

I expect the argument to be true.

About app

React Native Expo app, testing on iOS Simulator. React native version 0.74.3, react-native-launch-arguments version 4.0.2, expo 51.0.22.

About environment

  • I'm on a MacBook Pro running Sonoma 14.6.1.

Logs

Logs
<!-- Replace this line with your logs. *DO NOT* remove the backticks! -->

Maestro version

1.37.9

How did you install Maestro?

Homebrew

Anything else?

This may just be a documentation bug. I am able to get this working by providing the argument as a string. When I do that it is available to my app as a boolean which is great. But the docs indicate that it can be set as a boolean in the yaml file which doesn't seem to be the case, at least not for React Native.

christinachimi avatar Sep 04 '24 19:09 christinachimi

@christinachimi were you able to fix this?

3KINGZ avatar Sep 20 '24 06:09 3KINGZ

@3KINGZ providing the argument as a string works, so it's "fixed" in that sense, but I still think either the docs or the actual functionality is wrong.

christinachimi avatar Sep 20 '24 14:09 christinachimi

I am seeing this issue, but I am also seeing an issue where on Android, my launch args are empty altogether. LaunchArguments.value() just returns an empty object.

kanzelm3 avatar Sep 26 '24 14:09 kanzelm3

@christinachimi thanks that works

3KINGZ avatar Sep 26 '24 17:09 3KINGZ

I am seeing this issue, but I am also seeing an issue where on Android, my launch args are empty altogether. LaunchArguments.value() just returns an empty object.

@kanzelm3 are you getting even after passing the arguments as a string type?

3KINGZ avatar Sep 26 '24 17:09 3KINGZ

I tested on Android with a the following:

appId: ${APP_ID}
---
- launchApp:
    arguments:
      isE2E: true
      coolThing: 'Launch app with E2E flag'

And using the following in my app:

import { LaunchArguments } from 'react-native-launch-arguments';

console.log('Launch Args:', LaunchArguments.value());

on Android I see this

image

AdamTyler avatar Oct 09 '24 19:10 AdamTyler

Just a heads up, if you are using Typescript you can do something like

type MyLaunchArgs ={
myArg:boolean
}
LaunchArguments.value<MyLaunchArgs>().myArg

Typescript will do the cast for you

cmw9706 avatar Oct 16 '24 14:10 cmw9706

Hey @christinachimi The fix is here -> https://github.com/iamolegga/react-native-launch-arguments/pull/83

DorianMazur avatar Feb 13 '25 10:02 DorianMazur

Fixed upstream in react-native-launch-arguments

Fishbowler avatar Mar 21 '25 22:03 Fishbowler

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. Thank you for helping keep us our issue tracker clean!

github-actions[bot] avatar Mar 29 '25 00:03 github-actions[bot]