App Update SDK
Integrating a third-party SDK for app updates can significantly enhance user experience and simplify the update management process for your app. However, as with any third-party library, there may be certain issues and challenges. This guide explains why you might need such an SDK integration and outlines potential issues you could encounter.
Why Integrate a Third-Party App Update SDK?
- Improved User Experience
RuStore In-App Updates SDK allows users to receive updates without having to leave the app or visit the app store, making the update process smoother and more convenient. - Enhanced Security
Regular updates can include security fixes. Integrating an update SDK ensures users always have the safest version of your application. - Rapid Delivery of New Features
Third-party update SDKs facilitate quick delivery of new features and improvements, which is particularly beneficial for actively evolving apps requiring frequent updates. - Reduced Developer Workload
Integrating a third-party update SDK automates the process of checking and installing updates, thus reducing the developer workload and allowing them to focus on improving app functionality.
Integrating RuStore Update SDK into Your App
Adding Dependencies
Adding any new SDK starts with adding its dependency to your application:
implementation("ru.rustore.sdk:appupdate:6.0.0")
For using the Update SDK, you'll need an Update Manager. Here’s how to create one:
val updateManager = RuStoreAppUpdateManagerFactory.create(context)
SDK Operational Conditions
Below are the prerequisites for SDK functionality.
- App uploaded to RuStore Console.
- App passed moderation (you don't have to publish the app).
- Test build signature (for example:
debug) of the app must match the signature of the app build that was uploaded to the console and passed moderation (for example,release).
- Android 8.0 or later.
- RuStore app version on the device is up-to-date.
- User is authorized in RuStore.
- RuStore app is allowed to install applications.
Checking SDK Availability
You can verify SDK availability using the getAppUpdateInfo() method, which returns an AppUpdateInfo object containing update information:
-
updateAvailability— update availability -
installStatus— update installation status if the user is already installing the update at the current time
For more about statuses, see the documentation.
Example of the getAppUpdateInfo() method:
ruStoreAppUpdateManager
.getAppUpdateInfo()
.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability == UpdateAvailability.UPDATE_AVAILABLE) {
// Update is available (you can register a listener and start downloading here)
}
}
.addOnFailureListener { throwable ->
Log.e(TAG, "getAppUpdateInfo error", throwable)
}
After confirming update availability, you can request the download status.
You'll need a listener for tracking the update download status:
ruStoreAppUpdateManager.registerListener { state ->
when (state.installStatus) {
InstallStatus.DOWNLOADED -> {
// Update ready for installation
}
InstallStatus.DOWNLOADING -> {
val totalBytes = state.totalBytesToDownload
val bytesDownloaded = state.bytesDownloaded
// Show download progress here
}
InstallStatus.FAILED -> {
Log.e(TAG, "Downloading error")
}
}
}
More about download statuses in the documentation.
Types of App Updates
RuStore Update SDK provides three types of updates:
FLEXIBLE(deferred update)SILENT(silent update)IMMEDIATE(forced update)
FLEXIBLE (Deferred Update)
The most common scenario:
- User sees RuStore's update confirmation UI dialog.
- Clicking Update shows an installation confirmation dialog.
- Upon installation completion, the app closes.
Example for a FLEXIBLE update:
startUpdateFlow(appUpdateInfo, AppUpdateOptions.Builder().appUpdateType(FLEXIBLE).build())
SILENT (Silent Update)
Updates without RuStore’s UI notification (silent download):
- User sees only the installation confirmation dialog (update downloads in background).
- Upon installation completion, the app closes.
Example for a SILENT update:
startUpdateFlow(appUpdateInfo, AppUpdateOptions.Builder().appUpdateType(SILENT).build())
IMMEDIATE (Forced Update)
Unlike the other types, forced updates interrupt the user experience, but they are critical in certain scenarios:
- Critical bug fixes that must reach users immediately.
- Important new feature rollouts requiring quick user adoption.
Checking forced update availability:
if (appUpdateInfo.isUpdateTypeAllowed(IMMEDIATE)) {
// Forced update is available
}
Use the check above for forced updates based on your internal logic:
startUpdateFlow(appUpdateInfo, AppUpdateOptions.Builder().appUpdateType(IMMEDIATE).build())
Upon successful download, no further action is needed until installation. Complete the update installation:
completeUpdate(AppUpdateOptions.Builder().appUpdateType(AppUpdateType.FLEXIBLE).build())
- Using
FLEXIBLE, the app restarts. - Using
SILENT, the app closes without restarting.