0

My Android Firebase Remote Config not working ( on IOS it working well)

on MainActivity.OnCreate

var mRemoteConfig = FirebaseRemoteConfig.Instance;
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
    .SetDeveloperModeEnabled(true)
    .Build();
mRemoteConfig.SetConfigSettings(configSettings);
mRemoteConfig.SetDefaults(Resource.Xml.remote_config_defaults);
int cacheExpiration = 10; //10 secs
if (mRemoteConfig.Info.ConfigSettings.IsDeveloperModeEnabled)
{
    cacheExpiration = 0;
}
var remoteFetchCompleteListener = new RemoteFetchCompleteListener();
mRemoteConfig.Fetch(cacheExpiration).AddOnCompleteListener(remoteFetchCompleteListener);

/******************************************/
class RemoteFetchCompleteListener : Java.Lang.Object, Android.Gms.Tasks.IOnCompleteListener
{
   public void OnComplete(Android.Gms.Tasks.Task task)
   {
       const string TAG = "MainActivity";
       if (task.IsSuccessful)
       {
           FirebaseRemoteConfig.Instance.ActivateFetched();
#if DEBUG
           Android.Util.Log.Debug(TAG, "Remote Config Fetched!");
           Android.Util.Log.Debug(TAG, "Remote Config TEST_REMOTE_CONFIG : {0}", FirebaseRemoteConfig.Instance.GetString("TEST_REMOTE_CONFIG"));
#endif
        }
        else
        {
            Android.Util.Log.Debug(TAG, "Remote Config not fetched...");
        }
    }
}

Here is output

[MainActivity] Remote Config Fetched!  
[MainActivity] Remote Config TEST_REMOTE_CONFIG :  
Pang
  • 9,564
  • 146
  • 81
  • 122
Tuan Hoang Anh
  • 994
  • 12
  • 31

1 Answers1

0

Why vote close ???
I have fixed error. If I use

var options = new FirebaseOptions.Builder()  
                    .SetApplicationId("xxx")  
                    .SetApiKey("xxx")  
                    .SetGcmSenderId("xxx")  
                    .SetDatabaseUrl("xxx")  
                    .SetStorageBucket("xxx")  
                    .Build();  
firebaseApp = FirebaseApp.InitializeApp(this, options);  

I never get FirebaseRemoteConfig.Instance.GetString("TEST_REMOTE_CONFIG")
But if I use google-services.json it can get value FirebaseRemoteConfig.Instance.GetString("TEST_REMOTE_CONFIG")

Tuan Hoang Anh
  • 994
  • 12
  • 31