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 you begin, make sure that Apptics is integrated into your project by following the Integration Guide. Declare 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()

Extract the key-value pairs listed below to create your custom UI. The different action methods you can use are onClickUpdate, onClickReminder, onClickIgnore, onClickNonSupportAlert, and onSendImpressionStatus. 

Use the below to construct the custom popup.

Copied'updateid': The ID corresponding to a specific update configuration.
 'currentversion': The version of the app installed on the device.
 'featureTitle': The title or heading for the version alert.
 'features': Update features or what's new.
 'remindMeLaterText': Localized text for the "Remind Me Later" action.
 'updateNowText': Localized text for the "Update" action.
 'neverAgainText': Localized text for the "Ignore" action.
 
 The 'option' key determines the type of UI selected for this update in the web console:
 option (1): Flexible update flow.
 option (2): Immediate update flow.
 option (3): Force update flow.
 Read More https://www.zoho.com/apptics/resources/user-guide/in-app-updates.html
 
 'reminderDays': The number of days before showing the popup again if the user chooses "Remind Me Later." These days can be configured from the web console.

 'forceInDays': A custom store URL to redirect when the user taps "Update/Download." This can also be configured from the web console.

 'alertType': The type of the alert - Android in-app updates / ZAnalytics:
 
 0: ZAnalytics custom UI alert
 1: ZAnalytics native UI alert
 2: Android in-app updates
 
 'customStoreUrl': You can redirect this URL to another store.

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.