Remote Config returns Key from wrong Environment.

Hi all!

I had a search but couldn’t see if anyone had encountered this before, sorry if I didn’t search hard enough.

My problem is I have two environments for Remote Config on UGS, ‘test’ and ‘production’. I am setting the environment id in my project based off if you’re in the editor or on a build like this.

#if UNITY_EDITOR
            string environmentId = "test";
#else
            string environmentId = "production";
#endif

I then go onto set the environment ID in my initialisation, as shown here:

            RemoteConfigService.Instance.FetchCompleted += ApplyRemoteSettings;
            RemoteConfigService.Instance.SetEnvironmentID(environmentId);
            Debug.Log("Env ID: " + environmentId);

(notice that I’m logging the environment id, this prints as ‘test’ in the console).

I later fetch one of my keys and log it to the console.

        string fetchedContext = RemoteConfigService.Instance.appConfig.GetString("AIContext");
        Debug.Log("Env ID: " + environmentId);

Here are my two environments
Prod


Test

and here is the console, showing that it’s fetching the string from the prod env…
9054055--1251328--upload_2023-6-3_13-15-33.png

Any help would be appreciated. I have tried reloading the unity editor as I thought maybe it was cached, but as it’s printing the correct environmentID I don’t think it’s that.

Cheers,

Damo

I worked it out while waiting for moderation :smile:

Turns out you can’t use an Environments ‘name’ you have to use it’s ID! silly me.

Here’s a photo of what I mean for anyone that finds this thread in the future.

9056995--1251967--upload_2023-6-5_11-4-10.png
and find these IDs on the dashboard
9056995--1251970--upload_2023-6-5_11-4-48.png

Mods you can mark this as answered now if you like!

1 Like