FAQ

Can I get the image type using a JSAPI?

Yes, you can use my.getImageInfo JSAPI to retrieve image information, including its type. See the following code sample for details:

copy
my.getImageInfo({
  src:'https://www.example.com',
  success:(res)=>{
    console.log(JSON.stringify(res))
  }
});

Can I trigger phone vibration using a JSAPI?

Yes, you can use the my.vibrate JSAPI. See the following code sample for details:

copy
my.vibrate({
  success: () => {
    my.alert({ title: 'Vibration on'});
  }
});

How do I resolve the JSAPI call denied error for custom JSAPIs?

This error occurs because your mini program lacks access to the specific custom JSAPIs. To fix this, add features that control access to these JSAPIs in Mini Program Platform. For more information, see Add a feature to a mini program.

How do I call JSAPIs in HTML5 mini programs?

You can call JSAPIs using the AlipayJSBridge interface. See the following code sample for details:

copy
window.AlipayJSBridge && AlipayJSBridge.call("jsapi Name", {parameter}, function (data) { 
  alert('Result: \n'+ JSON.stringify(data));
});

Why does a mini program's settings page (opened via the my.openSetting JSAPI) show an empty list of permissions, and how do I resolve it?

An empty permissions list means that the user has not granted any permissions to the mini program. The settings page displays only permissions that have been explicitly granted at least once (these permissions will remain visible even if the user later revokes them).

How do I troubleshoot unresponsive my.request calls in a mini program?

To troubleshoot, take the following steps:

  1. Check domain allowlist configuration

Requests to domains not on the allowlist are blocked for security. To confirm whether the domains in your my.request calls are allowlisted:

    1. Log in to Mini Program Platform. Go to the mini program details page.
    2. Check either the global or version-specific configuration to see if the domains are included in Server Domains.
    3. Add any missing domains to Server Domains. For more information, refer to Configure mini programs.

If the issue persists, proceed to step 2.

  1. Check backend service health

The request might fail due to backend issues. To diagnose, use network packet capturing tools to inspect your request and confirm the backend service is operational. If the backend functions correctly, proceed to step 3.

  1. Use synchronous-style handling

For mini programs with the basic library version 2.0 (Lib v2.0), modify the code structure and use synchronous-style handling to capture the response directly. See the following code sample for details:

copy
const res = my.request({ url: 'https://www.example.com' });

Why does my.navigateBack redirect to the wrong page level when using the delta parameter?

This issue occurs due to an incorrect delta value. To calculate a correct delta, use the getCurrentPages method to retrieve the current page stack.

How do I disable screenshots and screen recording in a mini program?

Use the allowSystemSnapshot JSAPI via my.call and set allow to false. See the following code sample for details:

copy
disallowCaptureIncall(){
  my.call('allowSystemSnapshot',{
    allow:false,
    success:()=>{
      my.showToast({content:"call.success",duration:3000})
    },
    fail: (res) => {
      my.alert({
        title: "call.failed",
        content: "" + JSON.stringify(res)
      });
    }
  });
},

How do I resolve the JSAPI call denied error when calling the my.uploadFile JSAPI?

This error occurs if the target API domain (upload domain) is not whitelisted. To resolve this, go to the mini program details page in Mini Program Platform and add the domain to Server Domains. For a step-by-step guide, refer to Configure mini programs.

Why does an error occur when selecting a file to upload in an HTML5 mini program on Android?

This error occurs because the incoming file type does not match the expected MIME type. Android relies on MIME types to handle file uploads using an Intent. If the MIME type provided by the HTML5 mini program does not meet the MIME specifications, Android cannot process the request properly, resulting in an error. To fix this, ensure the file type is one of the following: image/png, image/jpeg, application/pdf, image/jpg, video/mp4, video/mov, or video/flv.

Why cannot click the full screen button on YouTube videos?

Reason:

There is a div element at the same level as the video player div. It has the following configurations:

  • set fullscreen
  • position: absolute
  • z-index: 99

These settings overlays the video player div, making all elements on the video player unclickable.

Solution: after removing the position:absolute, the button is clickable.

Why the MapContext.clearRoute, MapContext.showRoute JSAPI are not available?

To make the MapContext.clearRoute and MapContext.showRoute JSAPI available, need to enable appx2.0 on IDE and need to upload the correct Google map key. For more information, see the API key in the MapContext.showRoute file.

How to change the title bar color for a mini program?

Try to use the following ways:

copy
bundle.putInt("titleBarColor", 0xFF0000)
bundle.putInt(RVParams.LONG_TITLE_COLOR, 0x00FF00)

Why failed to call the my.request JSAPI?

Solution:

  • The interface domain name of the request needs to add in the whitelist in the background of the program.
  • Load the JSAPI writing adaptation with appx2.0. Writing can be const res = my.request.

Contact our support team if you needed.

Why failed to call JSAPIs on H5?

To reference the following scripts, where the versions 3.1.2 and 2.10.0 are used:

  • <script src="https://cdn.marmot-cloud.com/page/hylid-bridge/umd/3.1.2/index.js"></script>
  • <script src="https://cdn.marmot-cloud.com/npm/hylid-bridge/2.10.0/index.js"></script>

How to get the minapp query parameter ?

Take the following URL as a sample, to get the query parameter, use the onLaunch method with the my.confirm JSAPI.

URL sample: mini://platformapi/startapp?_ariver_appid=216602022*****&query={"path":"zakat","program_uuid":"*****-92ba-*****-a5d1-*****”}

Solution:

copy
App ({
    onLaunch (options) {
        my.confirm({
            title: 'Tips',
            content: options.query,
            confirmButtonText: 'Inquire now',
            cancelButtonText: 'Not needed',
        }) ;
    }
)}

How to use RSA OAEP encryption?

In the Package.json file, add the dependencies key-value pair. Take the following code as an example:

copy
“dependencies": {
“is-crypto-key-utils": ”^1.0.7.
“js-crypto-rsa": ”^1.0.7”
}

Demo code:

copy
// The gateway interface entry RSA encryption class
export const encryptHeader = (
// bdgatewayencryptionptiontype: 'bd66”, // base64
bdgatewayencryptiontype: 'rsa', // base64, // bdgatewayencryptiontype: 'bd66', // base64
}.
export const decryptHeader = {
// bdgateway responseneedencryptiontype: 'bd66', // base64
bdgatewayresponseneedencryptiontype: 'rsa', }

How to remove the custom JSAPI?

There is no deletion function to remove the custom JSAPI. But you can remove the corresponding custom JSAPI feature in the mini program management portal. Contact our support team if you needed.

How to customize a JSAPI?

Follow these topics to customize JSAPIs:

Is there any JSAPI in the mini program that can directly open an external browser?

To achieve this function, need to customize JSAPIs per your business demands:

How to upload videos to merchants' storage in the mini program?

Upload the selected video by using the my.chooseVideo JSAPI that works with the my.uploadFile JSAPI together.

Code sample:

copy
Page({
  uploadFile() {
    my.chooseVideo({
      sourceType: ['album', 'camera'],
      maxDuration: 60,
      camera: 'back',
      success(res) {
        console.log('chooseVideo', res);
        const path = res.tempFilePath;
        console.log(path);
        my.uploadFile({
          url: 'https://httpbin.org/post',
          fileType: 'video',
          fileName: 'user-selected-video',
          filePath: path,
          formData: { extra: 'Extra information' },
          success: res => {
            console.log('success res', res);
            my.alert({ title: 'Uploaded successfully' });
          },
          fail: err => {
            my.alert({ title: 'Failed to upload', content: JSON.stringify(err) });
          },
        });
      },
    });
  },
});

Can a mini program open XML documents ?

This function is not supported yet.

Why the password is not hidden when entering it on the mini program?

Reasons:

  • The type attribute of the input component is number.
  • So the component provides a numeric keypad for the user to enter the pin code. If you set the password property to true and display the entered number as a mask (***), such a combination does not work in the mini program. The password is still displayed in plain text. The customer tested in iOS with no problems because a custom keyboard is called, but Android used the system keyboard.

Workaround:

The app will pop up a keyboard with mixed numbers and letters. Add a logic to allow users to enter numbers only. So when entering other than numbers, it will pop up a red error message o remind the user that the feedback has been submitted and please wait for a while.

Why does the JSAPI call denied error occur when calling the my.request JSAPI?

You can try to solve the problem by the following checklist:

  • Add the required server domains to the whitelist under Mini Program > Configuration > Server Domain Whitelist.
  • Release the mini program in the sandbox environment, test environment, or development environment. Otherwise, the updated configuration does not take effect.
  • Check whether the JSAPI is private. If the called JSAPI is private, get the permission to call the JSAPI from the wallet first.

Why does the No privilege error occur when I call some JSAPIs?

Check whether the JSAPI is private. If the called JSAPI is private, get the permission to call the JSAPI from the wallet first.

Why should developers use my.getAuthCode JSAPI?

All the reading and writing of user information on the Mini Program Platform can only be used after obtaining the user's consent. User authorization is based on the industry standard OAuth2.0 authorization mechanism. With this mechanism, developers can obtain user information on the Mini Program Platform.

For more information, see User authorization.

Why is the user authorization API not allowed on the first screen of the mini program?

In order to create a better user experience on the mini program, user authorization guidance is not allowed on the first screen of the mini program. The guidance for user authorization should be given after the user fully understands the business content of the mini program. We recommend you add the mini program authorization into the business process.

For more information, see User authorization.

Can userId be obtained through the user authorization API?

No, the userId needs to be obtained by calling the related API on the server side.

For more information, see User authorization.