registerBridge
The registerBridge API is called by the super app to register the newly created or overridden built-in JSAPIs to IAPMiniProgram SDK.
Method signature
copy
void registerBridge(GriverBridgeManifest bridgeManifest, GriverContainerAPICallBack callBack) Request parameters
Name | Type | Description | Required |
bridgeManifest | The class information of the JSAPI. | M | |
callBack | The callback that is used to listen for the result of the JSAPI registration. | O |
Response parameters
Name | Type | Description | Required |
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 | Parameter error. | 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 TestBridgeExtension : SimpleBridgeExtension() {
@ActionFilter
@ThreadType(ExecutorType.UI)
fun test(
@BindingApiContext apiContext: ApiContext?,
@BindingCallback bridgeCallback: BridgeCallback
) {
val result = JSONObject()
result.put("test", "test")
bridgeCallback.sendJSONResponse(result)
}
}
Griver.registerBridge(GriverBridgeManifest(TestBridgeExtension::class.java, Arrays.asList<String>("test"))) { errorCode, errorMessage ->
//Return the errors when the registration fails
}Java
copy
public class TestBridgeExtension extends SimpleBridgeExtension {
@ActionFilter
@ThreadType(ExecutorType.UI)
public void test(@BindingApiContext ApiContext apiContext,
@BindingCallback BridgeCallback bridgeCallback) {
JSONObject result = new JSONObject();
result.put("test", "test");
bridgeCallback.sendJSONResponse(result);
}
}
Griver.registerBridge(new GriverBridgeManifest(TestBridgeExtension.class, Arrays.asList("test")), new GriverContainerAPICallBack() {
@Override
public void error(int errorCode, String errorMessage) {
//Return the errors when the registration fails
}
});