我的Android Firebase远程配置无法正常工作(在IOS上运行良好)
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...");
}
}
}
这是输出
[MainActivity] Remote Config Fetched!
[MainActivity] Remote Config TEST_REMOTE_CONFIG :
答案 0 :(得分:0)
为何投票结束?
我有修正错误。如果我使用
var options = new FirebaseOptions.Builder()
.SetApplicationId("xxx")
.SetApiKey("xxx")
.SetGcmSenderId("xxx")
.SetDatabaseUrl("xxx")
.SetStorageBucket("xxx")
.Build();
firebaseApp = FirebaseApp.InitializeApp(this, options);
我从未获得过FirebaseRemoteConfig.Instance.GetString(“TEST_REMOTE_CONFIG”)
但如果我使用google-services.json,它可以获得价值FirebaseRemoteConfig.Instance.GetString(“TEST_REMOTE_CONFIG”)