I'm trying to set up Firebase Remote Config for my project. I added Firebase via the Assistant. I added values to the server values on Google Cloud Console:
I've created default values xml in res/xml
<defaultsMap>
<!-- Strings-->
<entry >
<key>textView_send_text</key>
<value >your phrase goes here.</value>
</entry>
</defaultsMap>
Thats my MainActivity:
final private FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
protected void onCreate(Bundle savedInstanceState) {
//..code..
//fetch from Firebase
fetchAll();
}
private void fetchAll(){
final FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
mFirebaseRemoteConfig.setConfigSettings(configSettings);
mFirebaseRemoteConfig.setDefaults(R.xml.defaults);
mFirebaseRemoteConfig.fetch()
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
Toast.makeText(MainActivity.this, "Fetch Succeeded",
Toast.LENGTH_SHORT).show();
mFirebaseRemoteConfig.activateFetched();
}else{
Toast.makeText(MainActivity.this, "Fetch Failed",
Toast.LENGTH_SHORT).show();
}
displayWelcomeMessage();
}
});
}
private void displayWelcomeMessage(){
String welcomeMessage = mFirebaseRemoteConfig.getString("textView_send_text");
Toast.makeText(this, welcomeMessage,
Toast.LENGTH_SHORT).show();
}
Toast output:
So Toast gets the value from xml/defaults not from the Cloud. It'd be much appreciated if somebody found where I made a mistake.
Using the Remote Config background function triggering provided by Cloud Functions for Firebase along with FCM, you can propagate Remote Config updates in real-time.
Getting started Run the sample on an Android device or emulator. Change one or more parameter values in the Firebase Console (the value of welcome_message , welcome_message_caps , or both). Tap Fetch Remote Config in the app to fetch new parameter values and see the resulting change in the app.
Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update. When using Remote Config, you create in-app default values that control the behavior and appearance of your app.
Firebase Remote Config is currently experiencing an global issue where write calls to projects that are utilizing Cloud Function integrations may be failing. Elevated failure rate with Firebase Remote Config.
For development testing, specify a cache expiration time of zero to force an immediate fetch:
mFirebaseRemoteConfig.fetch(0) // <- add the zero
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
...
});
Some tips the helped to me:
"publish changes"
in Firebase console after each value updatemFirebaseRemoteConfig.fetch(0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With