registerEventHandler

The registerEventHandler API is used by the super app to register the SDK event handler.

Method signature

copy
void registerEventHandler(GriverEventManifest manifest, GriverContainerAPICallBack callBack) 

Request parameters

Name

Type

Description

Required

manifest

GriverEventManifest

The object of event handler.

M

callBack

GriverContainerAPICallBack

The callback that is used to return the result of the event hander registration.

O

Response parameters

Name

Type

Description

Required

error

Error

An object that is used to return the error code and error message when the registration fails.

O

Error codes

Error code

Error message

Further action

90002

GRV_CONTAINER_NOT_INITIALIZED

IAPMiniProgram SDK is not initialized.

Initialize the SDK.

90003

GRV_CONTAINER_ERROR_UNKNOWN

The request parameters are not specified correctly.

Refer to the Request parameters table and check if all parameter types are correct and if all required parameters are specified.

Samples

Kotlin

copy
class DemoGriverBackPressedPointEvent : GriverBackPressedPointEvent {
    override fun onInitialized() {

    }

    override fun onFinalized() {

    }

    override fun handleBackPressed(page: Page?) {
        // todo click back
    }
}
Griver.registerEventHandler(GriverEventManifest(DemoGriverBackPressedPointEvent::class.java.getName(), Arrays.asList<String>(GriverTitleBarCloseClickEvent::class.java.getName()),App::class.java)) { error, errorMessage -> }

Java

copy
public class DemoGriverBackPressedPointEvent implements GriverBackPressedPointEvent {
    
    @Override
    public void handleBackPressed(Page var1) {
    }
    
    @Override
    public void onInitialized() {
    }
    
    @Override
    public void onFinalized() {
    }
}

Griver.registerEventHandler(new GriverEventManifest(DemoGriverBackPressedPointEvent.class.getName(), Arrays.asList(GriverTitleBarCloseClickEvent.class.getName()), App.class), new GriverContainerAPICallBack() {
    @Override
    public void error(int error, String errorMessage) {

    }
});