# Permission Interface FAQ

# 1. Which interfaces are required for Mini-Programs to obtain permissions?

In the native pages of Mini-Programs, the following interfaces can be used to obtain corresponding permissions:

# 1.1 iOS

  • Camera Permission: QR code scanning interface (scanCode), image selection interface (chooseImage) for taking photos, video selection interface (chooseVideo) for recording, Camera Component (CameraContext);
  • Photo Album Read Permission: Image selection interface (chooseImage) for reading photos from the album, video selection interface (chooseVideo) for reading videos from the album;
  • Photo Album Write Permission: Save image to album (saveImageToPhotosAlbum), save video to album (saveVideoToPhotosAlbum);
  • Microphone Permission: Recording interface (startRecord), video selection interface (chooseVideo) for recording, Camera Component (CameraContext);
  • Geolocation Permission: Get geolocation interface (getLocation), select geolocation interface (chooseLocation), view location using map (openLocation), open POI list to select location (choosePoi), Map Component;
  • Bluetooth Permission: A series of APIs including Bluetooth - General, Bluetooth - Low Energy Central Device, Bluetooth - Low Energy Peripheral Device, Bluetooth - Beacon;
  • Background Audio Playback: BackgroundAudioManager capability for background audio playback requires users to manually add Background Modes under target-capabilities and check audio, AirPlay, and Picture in Picture.

# 1.2 Android

  • Camera Permission: QR code scanning interface (scanCode), image selection interface (chooseImage) for taking photos, video selection interface (chooseVideo) for recording;
  • Microphone Permission: Recording interface (startRecord);
  • Storage Permission: File selection interface (chooseMessageFile), image selection interface (chooseImage) for selecting from album, video selection interface (chooseVideo) for selecting from album;
  • Geolocation Permission: Get geolocation interface (getLocation), select geolocation interface (chooseLocation);

# 1.3 Detailed Interface Documentation

# 2. Which interfaces are required for HTML5 pages to obtain permissions?

In the HTML5 pages of Mini-Programs, the following interfaces can be used to obtain corresponding permissions:

# 2.1 iOS

  • Camera Permission: Image selection interface (ft.miniProgram.chooseImage) for taking photos
  • Photo Album Permission: Image selection interface (ft.miniProgram.chooseImage) for selecting from album

# 2.2 Android

  • Camera Permission: Image selection interface (ft.miniProgram.chooseImage) for taking photos
  • Storage Permission: Image selection interface (ft.miniProgram.chooseImage) for selecting from album

Note: Currently, the JSSDK related to permissions only supports the interface (ft.miniProgram.chooseImage).

# 2.3 Detailed Interface Documentation

# 3. What information is returned if permission acquisition fails, and how should it be handled?

There are two scenarios for failing to obtain permissions:

  1. Firstly, the SDK supports configuring the SDK to prohibit Mini-Programs from actively requesting permissions from the APP. Once configured, the SDK will prevent Mini-Programs from actively calling interfaces to request permissions.
    In this case, when permissions are requested in Mini-Program pages (whether H5 pages or native Mini-Program pages), the fail callback method passed when calling the API will be executed, returning res, where errMsg contains the reason for failure (e.g., chooseImage:fail unauthorized disableauthorized, indicating no photo album access permission).

    For documentation on how to disable SDK permission requests, refer to:

  2. Secondly, if the user has not granted permission, calling the API will fail and execute the fail callback method, returning res, where errMsg contains the reason for failure (e.g., chooseImage:fail unauthorized);

For both scenarios where permissions cannot be obtained, whether in Mini-Program pages or H5 pages, it is necessary to implement a prompt dialog based on the failure information returned in the callback, informing the user to enable the corresponding permissions. For example, if the callback indicates a failure due to lack of camera or photo album permissions (fail), a dialog prompt should be added to the page, such as "Please allow the APP to access your camera or photo album permissions in the system settings."

© FinClip with ❤ , Since 2017