How To Avoid Unnecessary App Releases

Michael H
The Startup
Published in
4 min readMay 4, 2020

--

Here’s a scenario for you: You’ve built an app now being used by thousands of people. It’s a huge success, but you want to really make it pop with some live updates. Let’s say on Halloween you want your app to be black and orange, but on Christmas you want users to see red and green. There’s a really simple way to do this, and it’s thanks to yet another great Firebase tool known as Remote Config.

The Trouble With App Rollouts:

Android and iOS app releases are notoriously difficult when it comes to implementing changes on the dime. Unlike making changes to a website, there is no “undo” button. Once a user updates to the newest version, they’re stuck there. This is why QA testing is so critical before an app update is released.

And to make things worse, you don’t get to flip a switch and have all users running your newest version. Releases rollout over time and some people just don’t update. Odds are you have active users on the past few versions of your app. Long story short, mobile change can be complicated.

Adding Flexibility With Remote Config:

With limited power over rollouts and no reverting updates, we need a way to make changes that aren’t dependent on the app store. Here’s where Remote Config comes in. It allows us to create variables in the Firebase portal and then access them in our app. So if we set up our app to respond differently depending on the variable, we can make changes seamlessly through Firebase.

We’ll go through the Android setup here, but the process is pretty much the same on iOS. If you don’t already have Firebase implemented in your project then you’ll need to do that as step 1. Then as with all 3rd party libraries we’ll have to update our app/build.gradle file. Add this implementation along with your other Firebase dependencies:

implementation ‘com.google.firebase:firebase-config:19.1.4’

After that’s set up, we can start adding Remote Config by getting an instance of FirebaseRemoteConfig and building the config settings:

val firebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
val remoteConfigSettings = FirebaseRemoteConfigSettings.Builder()
.setMinimiumFetchIntervalInSeconds(3600)
.build()
firebaseRemoteConfig.setConfigSettingsAsync(remoteConfigSettings)

This code creates a singleton object we can use to store in-app default values or fetch updated values from the Firebase console (i.e. outside of our app). The 3600 is a second count for how long we should wait before checking if the values have changed. For debugging/development it can be useful to set this to 0.

Let’s oversimplify our app and say it has a String value for the main color we will present to the user. Without any theme in place we want the base color to be white. So we can set this by creating a map of values and passing it in to the FirebaseRemoteConfig method setDefaultsAsync:

val defaults = HashMap<String, Any>()
defaults[“main_color”] = “White”
firebaseRemoteConfig.setDefaultsAsync(defaults)

Now that the app is able to get a value even when we don’t have Remote Config set up, let’s set it up. In our app’s Firebase Console let’s select Remote Config under Grow. Here we’ll be able to easily type in our key-value pair for the active color.

Click Add parameter and we’re all set in the console. Yes, it really is that easy.

Of course, we need to actually retrieve this value in the app. Back in our code let’s call the fetchAndActivate method:

firebaseRemoteConfig.fetchAndActivate()
.addOnCompleteListener {
if (it.isSuccessful) {
val updated = task.getResult()
val newColor =
firebaseRemoteConfig.getString(“main_color”)
//Call some other method that sets the app’s color
setAppColor(newColor)
}
}

And just like that we’re able to make live updates to our app without releases. It’s a pretty simple process, but the implications are powerful. There are tons of features you could change using this strategy. You could toggle certain portions of your app on/off, or completely change how features behave. I wouldn’t recommend abusing the power too much, but you could also pass full JSON stringified objects through with this strategy.

The sky is really the limit on what you can do with this powerful tool. So quit worrying about your next app rollout and set up Remote Config to help with changes that need to take place on the fly.

If you found this post helpful and want to learn more about Android or iOS development visit FreeMobileTutorials.com for more tutorials!

--

--

Michael H
The Startup

I’m a self taught Android, iOS and VR developer fascinated with the world of mobile. I’m passionate about learning new technologies by way of teaching others.