As Android Devs, many times we face the need to force an update of the app we’ve published into the Google Play Store.
Either because we want to lower the costs of maintenance of older versions, or because we decided to make changes in the app database, or any other reason, it is important to make sure that every user in our app has the latest version.
In Android, auto-updates are activated by default, but they may not get installed at the time they’re available, and in some cases this feature may have been deactivated manually by the user.
Because of all that, here are 3 ways to verify the app version the user has installed on their device and, in case there is a new version available, invite them to proceed with the update.
Communication with back-end
If we manage our own back-end, we can have a table in the database with the current version of the app published in the Play Store, and create an endpoint which returns that value. That way, if we store the current app version on a constant in the code, we can make the proper request to that endpoint in any part of the normal flow of the app we may need (for example, before performing the login), and make the comparison. If the version returned from BE is newer than the one we have in the code, we can stop the flow and invite the user to update the app with a custom dialog.
Firebase Remote Config
The previous approach can be used even if we don’t have a proper back-end which returns the value from a table in a database. In the Firebase Remote Config platform, different parameters can be defined with a value to be requested later in our app. Then we proceed in the same way we would do it if the parameter was returned from an endpoint in the back-end.
Google offers - of course - a native solution through the implementation of the Play Core library. It provides different features, such as defining the priority of the update, suggesting and forcing the users to download the latest version, and a callback method to be executed once the update is finished.
As we now have seen, there are different options between which we, as developers, can choose to force the update of the users’ app. Even if we don’t consider it necessary initially, it is highly recommended to implement one of these approaches since the first version of the app becomes productive, to be able to face any further problem that we may encounter.