GriverInterceptBackEventExtension

IAPMiniProgram SDK provides the ability to customize whether to intercept the physical return/back button press events. Follow this topic to realize this ability by implementing the specific interface of IAPMiniProgram SDK.

Procedures

To realize the customization, follow these steps:

Step 1. Implement the GriverInterceptBackEventExtension interface

Implement the GriverInterceptBackEventExtension interface and write code in the required methods according to your business logic. See the following example for how to implement this interface.

copy
class CustomInterceptBackEventExtension : GriverInterceptBackEventExtension {
    override fun intercept(appNode: AppNode?): Boolean {
        //customize the business logic
        return true
    }
}

Step 2. Register the CustomInterceptBackEventExtension class

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

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

Interface

GriverInterceptBackEventExtension interface

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

copy
interface GriverInterceptBackEventExtension : GriverExtension {
    fun intercept(appNode: AppNode?): Boolean
}

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

Method

Description

intercept

This method is triggered when the physical back button press events occur.

  • If this method returns "true", it indicates the Super App intercepts this event.
  • If this method returns "false", it indicates the Super App does not intercept this event.

Methods

intercept method

Parameter

Data type

Required

Description

appNode

AppNode

Yes

Indicates whether to intercept this back event.