Skip to content

Instantly share code, notes, and snippets.

@ccjeng
Last active September 26, 2016 04:30
Show Gist options
  • Save ccjeng/65de901175196548d3e87471df4d7a52 to your computer and use it in GitHub Desktop.
Save ccjeng/65de901175196548d3e87471df4d7a52 to your computer and use it in GitHub Desktop.
Firebase Remote Config
final FirebaseRemoteConfig mRemoteConfig = FirebaseRemoteConfig.getInstance();
// cache expiration in seconds
long cacheExpiration = 3600; //1 hour
//Settings
FirebaseRemoteConfigSettings remoteConfigSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(true)
.build();
mRemoteConfig.setConfigSettings(remoteConfigSettings);
//expire the cache immediately for development mode.
if (mRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cacheExpiration = 0;
}
//Fetch parameter values from the Remote Config Server
mRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
//Make the values available to your app
mRemoteConfig.activateFetched();
//get value from remote config
String testString = mRemoteConfig.getString("test");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment