Last active
September 26, 2016 04:30
-
-
Save ccjeng/65de901175196548d3e87471df4d7a52 to your computer and use it in GitHub Desktop.
Firebase Remote Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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