How to detect prod client vs standalone?

Please provide the following:

  1. SDK Version: 36.0.0
  2. Platforms(Android/iOS/web/all): Android/iOS

I’ve got an app that uses callback URLs for AWS Cognito authentication to allow for sign-in with Apple and Google.

When the app is published via Expo, the iOS app configured for Test Flight receives OTA updates.

The callback URLs need to differ when the app is running in the Expo client vs. stand alone (i.e. Test Flight). For example: exp://exp.host@myname/my-app vs. myapp://

The configuration for these URLs are done in a file that loads when the app does, much like how app.json works with Expo.

I’m trying to figure out how to dynamically configure the URLs based on whether the app is launched in the client or standalone, but I can’t see any way to do that.

I guess the backup plan would be to have a separate publish: one for prod in client and the other for prod stand alone.

Ideas?

Any advice is appreciated.

Thanks.

What we did is read the: __DEV__ global variable. Which will be available only when running it in Expo. Once you build it to a release channel (staging, prod or release) or whatever you named it, it will be false and you can use a different config.

On the other hand, we implemented expo-env - npm to maintain per-environment configuration on build time. There based on the release channel we load in our different env vars (which will be loaded in the app.json extra field).

I hope this helps.

1 Like

Thanks for the helpful reply @dept

I’m curious as to how __DEV__ would be different in, for example, staging (expo client) vs. prod (stand alone). Aren’t both running in Expo production mode, and thus false or am I missing something?

I’ll test this out to answer that myself, and let you know.

Also, I hadn’t come across the expo-env package before; thanks again.

I’ve been using a combination of multiple config files and package.json scripts, like the below, which is somewhat tedious.

I’ll check out expo-env, to see if it can streamline my workflow, and report back here on this as well.

  "scripts": {
    "android": "expo start --android",
    "publishStaging": "cp app.staging.json app.json && cp aws-config.staging.js aws-config.js && expo publish",
    "publishProd": "cp app.prod.standalone.json app.json && cp aws-config.prod.standalone.js aws-config.js && expo publish",
    "publishExpo": "cp app.prod.expo.json app.json && cp aws-config.prod.expo.js aws-config.js && expo publish",
    "pushDevelop": "git push --follow-tags origin develop",
    "pushMaster": "git push --follow-tags origin master",
    "levelUp": "standard-version.cmd",
    "levelUpDry": "standard-version.cmd --dry-run",
    "levelUpMajorDry": "standard-version.cmd --release-as major --dry-run",
    "levelUpMajor": "standard-version.cmd --release-as major",
    "levelUpMinorDry": "standard-version.cmd --release-as minor --dry-run",
    "levelUpMinor": "standard-version.cmd --release-as minor",
    "levelUpPatchDry": "standard-version.cmd --release-as patch --dry-run",
    "levelUpPatch": "standard-version.cmd --release-as patch",
    "eject": "expo eject",
    "ios": "expo start --ios",
    "start": "cp app.staging.json app.json && cp aws-config.staging.js aws-config-.js && expo start",
    "startExpo": "cp app.prod.expo.json app.json && cp aws-config.prod.expo.js aws-config-.js && expo start",
    "startProd": "cp app.prod.standalone.json app.json && cp aws-config.prod.standalone.js aws-config-.js && expo start",
    "test": "jest",
    "web": "expo start --web"
  },

(cmd suffixes are due to running in Powershell)

You are correct, in that case: Constants - Expo Documentation

That one should do the trick.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.