Getting app launch arguments

I have an app using Ionic 8/Capacitor 6 and am beginning to run automated testing using maestro as my test tool. I have a situation where I’d like to determine if the app is running using maestro to mock certain behaviors (e.g. barcode reading). Here’s my app info:

Ionic:
   Ionic CLI                     : 7.2.0 (/Users/ken/.nvm/versions/node/v20.15.1/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 8.2.7
   @angular-devkit/build-angular : 18.2.0
   @angular-devkit/schematics    : 18.2.0
   @angular/cli                  : 18.2.0
   @ionic/angular-toolkit        : 11.0.1

Capacitor:
   Capacitor CLI      : 6.1.2
   @capacitor/android : 6.1.2
   @capacitor/core    : 6.1.2
   @capacitor/ios     : 6.1.2

Looking at the maestro docs, I see that the app can be started with custom launch arguments and I’d like to use that to determine if maestro is being used.
The docs say


Their examples of retrieving launch arguments are geared toward native apps or react native (https://maestro.mobile.dev/api-reference/commands/launchapp#launch-arguments) but I can’t find a way to do this using Capacitor/Ionic.

I know that apps normally don’t have startup arguments but this is specifically for testing and won’t be used otherwise. This app does not have (and doesn’t need) a custom URL scheme so passing parameters that way is not an option. Can anybody point me in the right direction of how to retrieve launch arguments or a plugin that allows me to do this?

Thanks!

I’m looking for this same thing, for roughly the same reason.

I did a quick search of the various github repos listed for the community plugins, but nothing referenced processInfo, so it seems like no one’s built a plugin for it yet. (or my search skills are lacking…)

Shouldn’t be too hard to build a simple one though. I’ll work on it when I get a chance.

what does process.argv have in your typescript code? That would be the ideal solution :slight_smile:

first step in creating a plugin is making sure there isn’t someone that already is working on it. Here’s the proposal: LaunchArguments · Issue #223 · capacitor-community/proposals · GitHub