In-app updates for Android apps
In-app update module is used to show new version available alerts in android as per the configuration done in the Apptics web console. Refer to the User Guide to do the configuration in the web console.
Add the SDK
- Before your begin, make sure that Apptics is integrated into your project by following the Integration Guide.
- Declaring in-app update dependency using Apptics BoM.
Copieddependencies {
// ...
/ Apptics BoM, latest version is mentioned in the integration guide.
implementation platform('com.zoho.apptics:apptics-bom:[latest-version]')
// Since BoM version is specified, no need to explicitly specify the dependency version.
implementation 'com.zoho.apptics:apptics-appupdates'
}
- If you do not use Apptics BoM you can directly declare the in-app update dependency with its version.
Copieddependencies {
// Have to explicitly mention the version, if you are not using BoM.
// latest version is mentioned in the integration guide.
implementation 'com.zoho.apptics:apptics-appupdates:[latest-version]'
}
Note: It is recommend to use Apptics BoM to avoid unnecessary compatibility issues.
- Initialize in-app update SDK in Application onCreate() method.
CopiedApptics.init(this)
Show version alert popup
To check for updates and present the updates pop-up, call the checkAndShowVersionAlert method in an appropriate place. Also, override the onActivityResult method in the activity in which the pop-up is presented and call the doOnActivityResult method with request and result code.
CopiedAppticsInAppUpdates.checkAndShowVersionAlert(activityInstance)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
AppticsInAppUpdates.doOnActivityResult(requestCode, resultCode)
}
Note: Please refrain from using 500 and 501 request codes as they are used in in-app update.
Google Play's flexible update
It is recommended to inform the user that the update is ready to install and request confirmation before restarting the app. Use the onFlexibleUpdateDownloaded callback to inform the user that the update is downloaded and installFlexibleUpdate() method to complete the installation and restart the app.
CopiedAppticsInAppUpdates.onFlexibleUpdateDownloaded = {
// Show update downloaded notification.
// complete the installation.
AppticsInAppUpdates.installFlexibleUpdate()
}
Build your own flow
We have provided a method to fetch the raw response object with the update configurations if an update is available for the current app version.
Call the checkForUpdates method in a worker thread. It will return null if the update is not available.
CopiedAppticsInAppUpdates.checkForUpdates()
To send version alert engagement stats to Apptics server, use sendStats method with appropriate AppticsInAppUpdateStats enum value.
CopiedAppticsInAppUpdates.sendStats(updateId : Int, event: AppticsInAppUpdateStats)
Refer to this link to troubleshoot in case of using Google Play's in-app update.