GriverDynamicFeatureExtension

If you want to optimize the MYWeb module dynamic download experience, for example whether a custom dialog box is displayed to explain the download reason, knowning the download status, and so on, to achieve these experiences, use the GriverDynamicFeatureExtension interface.

Note:This interface is applicable to SDK version 2.71.0 and the later versions.

Procedures

Step 1. Implement the GriverDynamicFeatureExtension interface

Implement the GriverDynamicFeatureExtension interface and write code in the required methods according to your business logic.

Code sample as follows:

copy
public class CustomGriverDynamicFeatureExtension implements GriverDynamicFeatureExtension {

    @Override
    public void showDialog(DynamicFeatureDialogCallback callback, @NonNull List<? extends InstallModuleType> list) {
    }

    @Override
    public void onUpdate(InstallSessionEnumStatus status, @NonNull List<? extends InstallModuleType> moduleTypes) {
    }

    @Override
    public void onAlreadyInstalled(@NonNull InstallModuleType moduleType) {
    }
}

Step 2: Register the CustomGriverDynamicFeatureExtension class

Refer to the following sample code and call the registerExtension interface to register after initializing the SDK.

copy
IAPConnect.init(application, initConfig, object : InitCallback() {
    override fun onSuccess() {
        //···
        Griver.registerExtension(
            GriverExtensionManifest(
                GriverDynamicFeatureExtension::class.java,
                CustomGriverDynamicFeatureExtension()
            )
        )
    }
})

Structures

GriverDynamicFeatureExtension interface

The definition of this interface is shown in the following codes:

copy
public interface GriverDynamicFeatureExtension extends GriverExtension {

    void showDialog(DynamicFeatureDialogCallback callback, @NonNull List<? extends InstallModuleType> list);

    void onUpdate(InstallSessionEnumStatus status, @NonNull List<? extends InstallModuleType> list);

    void onAlreadyInstalled(@NonNull InstallModuleType moduleType);

    interface DynamicFeatureDialogCallback{
        void onConfirm();

        void onCancel();
    }
}

Methods

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

Method

Description

showDialog

After the app starts and MYWeb module is ready to download, the app controls whether a custom dialog box is displayed. The logic is customized. For example, after the user refuses to view the dialog box the multiple times, the dialog will no longer pop up.

onUpdate

Callback of the MYWeb module download status.

onAlreadyInstalled

Callback of the MYWeb module installation status, which is used to handle the already installed module.

showDialog method

This method supports the following parameters:

Parameter

Data type

Required

Description

callback

DynamicFeatureDialogCallback

Yes

When clicking Confirm or Cancel on the dialog box, the callback is passed to the SDK.

list

List<? extends InstallModuleType>

Yes

Indicates the module type.

Note: only MYWEB type is supported.

onUpdate method

This method supports the following parameters:

Parameter

Data type

Required

Description

status

InstallSessionEnumStatus

Yes

Indicates the module download status:

  • INSTALLED: Install the module successfully.
  • FAILED : Fail to install the module.
  • CANCELED: Cancel the installation of this module.

list

List<? extends InstallModuleType>

Yes

Indicates the module type.

Note: only MYWEB type is supported.

onAlreadyInstalled method

This method supports the following parameters:

Parameter

Data type

Required

Description

moduleType

InstallModuleType

Yes

Indicates the module type.

Note: only MYWEB type is supported.