Implement the Callbacks

To implement the Auto Update SDK, include the following callback methods:

MethodDescription
onInitializationSuccessTriggered when SDK initialization is successful.
onUpdateStatusTriggered when a new version of the app is available, and immediately after invoking thecheckForUpdate()method.
onDownloadStartedTriggered when permission to install has been granted by the player, and the download process begins. The SDK will attempt to download the new app version.
onProgressTriggered when the download is initiated and when every new byte or packet is downloaded thereafter. You may use it to show download progression in real-time.
onDownloadEndedTriggered when the download process is complete.
onInstallationReadyTriggered when the SDK is ready to start the installation process.
onErrorTriggered when an error occurs during the update process, excluding initialization failures. Follow the instructions in the Auto Update SDK troubleshooting article and try to re-initialize again based on the error.

Example code

Below is the example code for the implementation:

bridgeAPI.init(this, config, object : IUpdateCallback {
    override fun onInitializationSuccess() {
        Log.v(tag, "Initialization successful.")
    }

    override fun onUpdateStatus(status: UpdateStatusModel) {
        Log.v(tag, "Checking whether a new version is available: ${status.isUpdateAvailable}")
    }

    override fun onDownloadStarted() {
        Log.v(tag, "Downloading the new app version.")
    }
    
    override fun onProgress(progress: Int) {
        Log.v(tag, "Progress: $progress")
    }

    override fun onDownloadEnded() {
        Log.v(tag, "The new app version has been downloaded.")
    }

    override fun onInstallationReady() {
        Log.v(tag, "The new app version has been downloaded and is ready to install.")
    }

    override fun onError(errorCode: Int) {
        Log.v(tag, "Error: $errorCode")
    }
})