Set up appcenter on react-native app w/.env vars

Setting up Microsoft App Center with React Native

I am using Microsoft App Center in my bare react-native app. To set up App Center, I need to add two files to my project:

iOS

Add AppCenter-Config.plist with the following content:

    <dict>
    <key>AppSecret</key>
    <string><MY_SECRET_KEY></string>
    </dict>

Android

Add a JSON file with the following content:

 {
    "app_secret": "<MY_SECRET_KEY>"
 }

Using React Native Config

I am already using the React Native Config package in my app to handle .env files. Is there any way to use this package or another one, in order to get the APP_SECRET for the App Center config files from an environment variable, so I don’t have to keep these keys under version control?

Yes, you can use React Native Config to get the APP_SECRET for the App Center config files from an environment variable. You would need to define the APP_SECRET variable in your .env file and then access it in your AppCenter-Config.plist and JSON file using the process.env.APP_SECRET syntax. For example:

iOS

In your .env file:

APP_SECRET=<MY_SECRET_KEY>

In your AppCenter-Config.plist file:

<dict>
<key>AppSecret</key>
<string>${APP_SECRET}</string>
</dict>

Android

In your .env file:

APP_SECRET=<MY_SECRET_KEY>

In your JSON file:

{
   "app_secret": "${APP_SECRET}"
}