Overview:
In projects with multiple environments (dev, stage, prod), it’s common to see Remote Config return production (or another environment) values on startup even when you’ve set a different environment. This typically happens when the first config fetch occurs before Remote Config has been targeted to the intended environment, or when assuming the Unity Services environment name maps automatically to Remote Config’s environment ID (UUID). Remote Config uses a distinct environment ID, and any early fetch will default to the environment tied to the current auth/session (often production).
Symptoms:
- Immediately after startup, you see two fetches:
- First fetch returns production values
- Second fetch returns dev/stage values
- Logs show IsDevEnvironment = False on the first fetch, then True on the second.
- You set an environment name in Unity Services, but Remote Config still fetches from production until explicitly targeted.
- Behavior is inconsistent unless explicitly setting Remote Config’s environment ID.
Cause:
- Remote Config does not automatically inherit the Unity Services environment name; it targets an environment UUID (environmentId).
- If you set Remote Config’s environment after Unity Services initialization, an early/automatic fetch may run first (defaulting to the auth session’s environment, often production).
- Setting the environment name for Unity Services alone does not guarantee Remote Config will use the same environment unless configured before the first fetch or explicitly targeted by environmentId.
Resolution:
- Ensure Remote Config is targeted to the intended environment before the first fetch:
- Set the intended environment during startup sequence, prior to any Remote Config fetch.
- If needed for reliability, explicitly set the Remote Config environment ID (UUID) once after initialization and before your first fetch; it should persist for the session.
- Avoid setting the environment ID before every fetch unless you intend to switch environments mid‑session; once set, Remote Config should stick to that environment.
- Review startup ordering to prevent any automatic/early fetch from defaulting to production (for example, defer fetch until after targeting is complete).
More Information:
- Remote Config uses environment IDs (UUIDs), not environment names. Ensure you’re targeting the correct UUID shown in the Dashboard for the environment you intend (dev, stage, prod).
- Keywords for search: Remote Config environmentId, environment name vs ID, production values on startup, double fetch on init, auth session default environment, SetEnvironmentID, InitializationOptions, FetchConfigsAsync.