Skip to content

[Bug] RemoteConfig ignores FirebaseApp on Android #991

Closed
firebase/firebase-cpp-sdk
#390
@Girildo

Description

@Girildo

Please fill in the following fields:

  • Unity editor version: 2019.4.3
  • Firebase Unity SDK version: 7.1.0
  • Source you installed the SDK: Unity Package Manager
  • Problematic Firebase Component: RemoteConfig
  • Other Firebase Components in use: Auth, Firestore, Crashlytics, Functions
  • Additional SDKs you are using: None
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: Mono

Please describe the issue here:

I have two Firebase projects, one for production and one as a test environment. I can swap between the two with no issues with every other Firebase component by doing, on startup,

  if (options == null)
  {
      Debug.LogError("Null app options. Falling back to PRODUCTION!");
      return FirebaseApp.DefaultInstance;
  }
  else
  {
      Debug.Log("Connected to test environment!");
      return FirebaseApp.Create(options, "TEST");
  }

I initialize RemoteConfig by means of

private FirebaseRemoteConfig RemoteConfigSettings(FirebaseApp app)
{
    var instance = FirebaseRemoteConfig.GetInstance(app);
    return instance;
}

and fetch data by doing

private async Task MyFunction()
{
    await this.firebaseRemoteConfig.FetchAsync(TimeSpan.Zero);
    await this.firebaseRemoteConfig.ActivateAsync();
}

In the editor, everything behaves consistently: the config value are fetched from the correct Firebase project.

In the Android build, however, regardless of the environment, the app fetches data from the production (and default) environment.
It is worth adding that the package name of both the test and the production environment are identical.

The following test code:

            await this.firebaseRemoteConfig.FetchAsync(TimeSpan.Zero);
            await this.firebaseRemoteConfig.ActivateAsync();

#if UNITY_EDITOR
            UnityEngine.Debug.Log("In editor:");
#elif UNITY_ANDROID
            UnityEngine.Debug.Log("In android build:");
#endif
            UnityEngine.Debug.Log("Firebase app name: " + this.firebaseRemoteConfig.App.Name);
            UnityEngine.Debug.Log("Value of \"env\" variable: " + this.firebaseRemoteConfig.GetValue("env").StringValue);

produces the following "output"
image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions