Use Custom JSAPI in mini program
For customizing JSAPI, there are two situations: customizing the existing JSAPI and adding a new JSAPI. Their usages may be a little different.
For customizing the existing JSAPI, the name of the JSAPI is already known in the Mini Program Framework, so mini program developers can call my.apiName
directly to use the existing API.
But for adding a new JSAPI, the name of the JSAPI is only known on the native side (Android or iOS), and the Mini Program Framework can not recognize the call if developers call my.apiName
because the apiName is unknown. So for these APIs, developers should use the following method to call the JSAPI.
my.call(apiName, params, callback);
For the detailed input parameters, refer to the following table.
Field | Type | Required | Description |
apiName | String | Y | The name of the JSAPI |
params | JSON | N | The params of the JSAPI call |
callback | function | N | The callback function of the JSAPI call |
Although you can use my.call
to call JSAPI, try to avoid using this method because the mini program may be abnormal in other apps if they do not implement these APIs.