my.showAuthGuide

Pop up dialog for user in form of (image, text, etc.) via the permission guide module. To advice the user to turn on the related permission. The permission guide is used to advice rather than to validate the permission. The call timing is when the service party confirms the required permission is limited. In addition, the permission guide pop-up is subject to fatigue and other factors.

Sample Code

copy
// API-DEMO page/API/show-auth-guide/show-auth-guide.json
{
    "defaultTitle": "Permission guide"
}
copy
<!-- API-DEMO page/API/show-auth-guide/show-auth-guide.axml-->
<view class="page">
  <view class="page-description">Permission guide API</view>
  <view class="page-section">
    <view class="page-section-title">my.showAuthGuide</view>
    <view class="page-section-demo">
      <button type="primary" onTap="showAuthGuide">Permission guide</button>
    </view>
  </view>
</view>
copy
// API-DEMO page/API/show-auth-guide/show-auth-guide.js
Page({
  showAuthGuide() {
    my.showAuthGuide({ 
        authType:'LBS',
        success:(res)=>{
            //When shown is true, it indicates the permission guide pop-up will be shown; when it is false, it indicates the user has allowed the permission.
            my.alert({content: 'Call success: '+JSON.stringify(res), });
        },
        fail:(error)=>{
            my.alert({content: 'Call failure:'+JSON.stringify(error), });
        },
    });
  },
});

Parameters

String type with the following attributes:

PropertyType

Required

Description
authTypeStringYesIdentifier of the permission under guide, used to identify the type of the permission (such as LBS).
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Supported authType

Permission namePermission code
Microphone permissionMICROPHONE
Addressbook permissionADDRESSBOOK
Camera permissionCAMERA
Photo permissionPHOTO
Lbs switchLBS