Skip to main content
Use this API to display a guide helping users understand and grant specific permissions. This is useful when a permission request was previously denied.

Parameters

PropertyTypeRequiredDescription
authTypeStringYesPermission type to guide for
successFunctionNoCallback on success
failFunctionNoCallback on failure
completeFunctionNoCallback that always executes

Auth Types

ValueDescription
LOCATIONLocation permission
CAMERACamera permission
PHOTOPhoto album permission
CONTACTSContacts permission
MICROPHONEMicrophone permission

Code Example

Basic Usage

my.showAuthGuide({
  authType: 'LOCATION',
  success() {
    console.log('Auth guide shown');
  }
});

Permission Request Flow

Page({
  async getLocation() {
    my.getLocation({
      success: (res) => {
        this.handleLocation(res);
      },
      fail: (err) => {
        // Show authorization guide
        my.showAuthGuide({
          authType: 'LOCATION',
          success: () => {
            // Guide was shown, user may have granted permission
            // Try again after a delay
            setTimeout(() => {
              my.getLocation({
                success: (res) => this.handleLocation(res),
                fail: () => {
                  my.showToast({
                    content: 'Location permission required',
                    type: 'fail'
                  });
                }
              });
            }, 1000);
          }
        });
      }
    });
  },

  handleLocation(res) {
    console.log('Location:', res.latitude, res.longitude);
  }
});

Camera Permission Guide

Page({
  takePhoto() {
    my.chooseImage({
      sourceType: ['camera'],
      success: (res) => {
        this.setData({ photo: res.tempFilePaths[0] });
      },
      fail: () => {
        my.showAuthGuide({
          authType: 'CAMERA',
          success: () => {
            my.showToast({
              content: 'Please grant camera permission and try again'
            });
          }
        });
      }
    });
  }
});

Multiple Permission Types

const permissionGuides = {
  location: () => my.showAuthGuide({ authType: 'LOCATION' }),
  camera: () => my.showAuthGuide({ authType: 'CAMERA' }),
  photo: () => my.showAuthGuide({ authType: 'PHOTO' }),
  contacts: () => my.showAuthGuide({ authType: 'CONTACTS' })
};

function showGuideFor(type) {
  if (permissionGuides[type]) {
    permissionGuides[type]();
  }
}
Use this API to provide a better user experience when permissions are denied. The guide helps users understand why the permission is needed and how to enable it.

my.openSetting

Open settings page

my.getLocation

Get location