What I am trying to do is to save the colorPrimay, colorDarkPrimary and so on, values in RemoteConfig of Firebase so that I could able to change the colors of the apps from remote config and I did following
UPDATE: What I am trying to do is to save the colorPrimay, colorDarkPrimary and so on, values in RemoteConfig of Firebase so that I could able to change the colors of the apps from remote confi. How could I do that?
UPDATE:
What I have tried is like
<--!remote_config_default.xml!-->
<defaultsMap>
<entry>
<key>primaryColor</key>
<value>#9c27b0</value>
</entry>
<entry>
<key>colorPrimaryDark</key>
<value>#7b1fa2</value>
</entry>
<entry>
<key>colorAccent</key>
<value>#FF4081</value>
</entry>
<entry>welcomeMessage</entry>
<value>Connection Failed</value>
And fetch like this
void applyRemoteConfig() {
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
mFirebaseRemoteConfig.setDefaults(R.xml.remote_config_default);
// cacheExpirationSeconds is set to cacheExpiration here, indicating that any previously
// fetched and cached config would be considered expired because it would have been fetched
// more than cacheExpiration seconds ago. Thus the next fetch would go to the server unless
// throttling is in progress. The default expiration duration is 43200 (12 hours).
int cacheExpiration = 1000;
final String TAG = "Riddles";
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "Fetch Succeeded");
// Once the config is successfully fetched it must be activated before newly fetched
// values are returned.
mFirebaseRemoteConfig.activateFetched();
} else {
Log.d(TAG, "Fetch failed");
String message = mFirebaseRemoteConfig.getString("welcomeMessage");
displayWelcomeMessage(message);
Log.d(TAG, message);
}
}
});
String message = mFirebaseRemoteConfig.getString("welcomeMessage");
displayWelcomeMessage(message);
Log.d(TAG, message);
}
But the
mFirebaseRemoteConfig.getString("colorPrimary");
mFirebaseRemoteConfig.getString("colorDarkPrimary");
mFirebaseRemoteConfig.getString("welcomeMessage");
Are returning Null.