# Custom API Management

When a Mini-Program needs to call certain capabilities provided by the Host-App, but the FinClip Mini-Program SDK has not implemented or cannot implement them, you can achieve this by registering custom APIs, enabling the Mini-Program to call APIs registered in the App.

Of course, when you need to use some unimplemented or unimplementable components, you can also register custom components.

Registering custom APIs is divided into two scenarios:

Registering custom APIs for use by native Mini-Programs;
Registering custom APIs for use by H5 pages loaded via the WebView component within a Mini-Program.

# 1 Register Custom API

Example

    MopSdk.registerExtensionApi(
       // Custom API name
       apiName,
       (ret) => {
          console.log('onCallback',ret)

          // Handle success/failure, return corresponding parameters
          MopSdk.onSuccess(ret.uuid,{

          })
          // Failure
          //MopSdk.onFail(ret.uuid,{})
       }
    );

Parameters

Configuration Name Type Configuration Description
apiName String Custom API Name
callback Function Custom API Callback Function

Retrieve Parameters Received by App

Configuration Name Type Configuration Description
uuid String Unique Identifier
event String Event Name
appId String Mini-Program ID
params Object Parameters Passed from Mini-Program

# 2 Unregister Custom API (Android Only)

Example

    MopSdk.unRegisterExtensionApi(apiName);

Parameters

Configuration Name Type Configuration Description
apiName String Custom API Name

# 3 Register Web-View Custom API

Example

    MopSdk.registerWebExtentionApi(
       // Custom API name
       apiName,
       (ret) => {
           console.log('onCallback',ret)
            // Success
            MopSdk.onSuccess(ret.uuid,ret)
          // Failure
          //MopSdk.onFail(ret.uuid,ret)
       }
    )

Parameters

Configuration Name Type Configuration Description
apiName String Custom API Name
callback Function Custom API Callback Function

# 4 Unregister Web-View Custom API (Android Only)

Example

    MopSdk.unRegisterWebExtensionApi(apiName)

Parameters

Configuration Name Type Configuration Description
apiName String Custom API Name
© FinClip with ❤ , Since 2017