In-App Updates via Android Billing SDK
Overview
Ensuring that users are directed back to the original app store for updates is crucial for maintaining a consistent and expected user experience.
This guide provides developers with the essential information and code snippets needed to implement in-app updates using the Android Billing SDK effectively. By accurately identifying the origin of the app installer and confirming its presence on the device, we can ensure users are redirected to the correct store for updates. This process guarantees that the app version being updated preserves the original billing agreements and settings, maintaining consistency and trust in the user experience.
Description
It features an Automatic App Updating flow for a simple and easy integration in the Application and also a manual mechanism for a more controlled and developer oriented flow.
Moving on to the implementation of the In-App Updates in your application, your first goal is to instantiate the client and connect to the Billing SDK. After retrieving the client, it can be used to execute either an Automatic or a Manual Update flow.
So the implementation consists of 2 steps:
- Setup connection with Catappult Billing SDK;
- App Update flow integration;
Step 1: Connect to the Android Billing SDK
For this, please follow the documentation in the Android Billing SDK - Setup Connection with Catappult Billing SDK .
Step 2: App Update flow integration
Automatic App Update flow
This mechanism relies on the Android Billing SDK to fully handle the app updates, using a pop-up dialog to ask the user to update the app to the newest version, redirecting them to the original app store.
Initiate this flow with the following approach:
private fun launchAutomaticAppUpdate(context: Context) {
cab.launchAppUpdateDialog(context)
}
private void launchAutomaticAppUpdate(Context context) {
cab.launchAppUpdateDialog(context);
}
Manual App Update flow
This mechanism relies on manual check for a new version availability and consequently, launching the original Store to perform the App Update.
Initiate this flow with the following approach:
private fun launchManualAppUpdate(context: Context) {
if (isNewVersionAvailable()) {
// You can perform a User prompt to verify if an App Update should be done
cab.launchAppUpdateStore(context)
}
}
private fun isNewVersionAvailable(): Boolean =
cab.isAppUpdateAvailable()
private void launchManualAppUpdate(Context context) {
if (isNewVersionAvailable()) {
// You can perform a User prompt to verify if an App Update should be done
cab.launchAppUpdateStore(context);
}
}
private boolean isNewVersionAvailable() {
return cab.isAppUpdateAvailable();
}
Best Practices
Make sure to check for network connectivity before requesting an App Update, or else the requests won't work.
Handle exceptions and errors gracefully, providing fallback options or user guidance as necessary.
Updated about 2 hours ago