AppUpdateIntervalExtension

You can customize intervals to control how often the SDK checks for new mini program versions for asynchronous and synchronous updates. Intervals are measured from the mini program's first launch or most recent update.

The following table shows how custom intervals apply to different update modes:

Update mode

Affected by async update interval

Affected by sync update interval

Default mode (uses both async and sync updates)

Yes

Yes

Async mode

Yes

No

Sync mode (checks for updates every time the mini program opens)

No

No

For more information about mini program updates, refer to Mini program update mechanism.

To customize update intervals, implement the AppUpdateIntervalExtension interface. This topic provides implementation steps and interface specifications.

Default experience

If you do not customize the update intervals, the SDK uses the following defaults:

  • Asynchronous updates: every one hour
  • Synchronous updates: every 10 days

Before you begin

Ensure that the integrated Android IAPMiniProgram SDK is version 2.65.7 or later. For more information, see SDK release notes.

Procedure

To customize the mini program update intervals, take the following two steps:

Step 1: Implement the AppUpdateIntervalExtension interface

Create a class that implements the AppUpdateIntervalExtension interface. Within the class, override the following methods as needed:

  • syncUpdateIntervalForApp: Customizes the interval for checking for synchronous updates.
  • asyncUpdateIntervalForApp: Customizes the interval for checking for asynchronous updates.

For more information about the interface and methods, refer to AppUpdateIntervalExtension. Refer to the following code for a sample implementation:

copy
class AppUpdateIntervalExtensionImpl : AppUpdateIntervalExtension {
    private var syncTime: Long = 10 * 24 * 3600
    private var asyncTime: Long = 3600

    override fun syncUpdateIntervalForApp(): Long {
        return syncTime
    }

    override fun asyncUpdateIntervalForApp(): Long {
        return asyncTime
    }
}

Step 2: Register the implementation class

After initializing the SDK, call the registerExtension API to register the implementation class (for example, AppUpdateIntervalExtensionImpl in the sample) with the SDK. Refer to the following sample registration code:

copy
IAPConnect.init(application, initConfig, object : InitCallback {
    override fun onSuccess() {
        //ยทยทยท
        Griver.registerExtension(
            GriverExtensionManifest(
                AppUpdateIntervalExtension::class.java,
                AppUpdateIntervalExtensionImpl()
            )
        )
    }
})

Structures

AppUpdateIntervalExtension interface

The AppUpdateIntervalExtension interface defines methods for the super app to customize intervals for synchronous and asynchronous mini program updates. Refer to the following code for the interface definition:

copy
interface AppUpdateIntervalExtension : GriverExtension {
    fun syncUpdateIntervalForApp(): Long {
        return 10 * 24 * 3600
    }

    fun asyncUpdateIntervalForApp(): Long {
        return 3600
    }
}

Based on the definition, this interface provides the following methods:

Method

Description

syncUpdateIntervalForApp

Called by the SDK to obtain the custom interval for synchronous updates. The super app needs to return the interval in seconds as a Long value.

If this method is not overridden, the SDK defaults to 10 days.

asyncUpdateIntervalForApp

Called by the SDK to obtain the custom interval for asynchronous updates. The super app needs to return the interval in seconds as a Long value.

If this method is not overridden, the SDK defaults to one hour.