# uni.getAppAuthorizeSetting()

获取 APP 授权设置。

# 返回值

类型
GetAppAuthorizeSettingResult
名称 类型 必备 默认值 描述
albumAuthorized "authorized" | "denied" | "not determined" - 允许 App 使用相册的开关(仅 iOS 支持)
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
bluetoothAuthorized "authorized" | "denied" | "not determined" | "config error" - 允许 App 使用蓝牙的开关(仅 iOS 支持)
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
- config error: Android平台没有该值;iOS平台:表示没有在 manifest.json -> App模块配置 中配置 BlueTooth(低功耗蓝牙) 模块
cameraAuthorized "authorized" | "denied" | "not determined" | "config error" - 允许 App 使用摄像头的开关
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
- config error: Android平台:表示没有配置 android.permission.CAMERA 权限,权限配置详情;iOS平台没有该值
locationAuthorized "authorized" | "denied" | "not determined" | "config error" - 允许 App 使用定位的开关
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
- config error: Android平台:表示没有配置 android.permission.ACCESS_COARSE_LOCATION 权限,权限配置详情;iOS平台:表示没有在 manifest.json -> App模块配置 中配置 Geolocation(定位) 模块
locationAccuracy "reduced" | "full" | "unsupported" - 定位准确度。
- reduced: 模糊定位
- full: 精准定位
- unsupported: 不支持(包括用户拒绝定位权限和没有在 manifest.json -> App模块配置 中配置 Geolocation(定位) 模块)
locationReducedAccuracy boolean | null - 定位准确度(推荐使用 locationAccuracy 属性)。true 表示模糊定位,false 表示精确定位(仅 iOS 支持)
microphoneAuthorized "authorized" | "denied" | "not determined" | "config error" - 允许 App 使用麦克风的开关
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
- config error: Android平台:表示没有配置 android.permission.RECORD_AUDIO 权限,权限配置详情;iOS平台没有该值
notificationAuthorized "authorized" | "denied" | "not determined" | "config error" - 允许 App 通知的开关
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
- config error: Android平台没有该值;iOS平台:表示没有在 manifest.json -> App模块配置 中配置 Push(推送) 模块
notificationAlertAuthorized "authorized" | "denied" | "not determined" | "config error" - 允许 App 通知带有提醒的开关(仅 iOS 支持)
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
- config error: 没有在 manifest.json -> App模块配置 中配置 Push(推送) 模块
notificationBadgeAuthorized "authorized" | "denied" | "not determined" | "config error" - 允许 App 通知带有标记的开关(仅 iOS 支持)
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
- config error: 没有在 manifest.json -> App模块配置 中配置 Push(推送) 模块
notificationSoundAuthorized "authorized" | "denied" | "not determined" | "config error" - 允许 App 通知带有声音的开关(仅 iOS 支持)
- authorized: 已经获得授权,无需再次请求授权
- denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
- not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
- config error: 没有在 manifest.json -> App模块配置 中配置 Push(推送) 模块
# GetAppAuthorizeSettingResult 兼容性
Android iOS web
albumAuthorized x 4.11 -
bluetoothAuthorized x 4.11 -
cameraAuthorized 3.9 4.11 -
locationAuthorized 3.9 4.11 -
locationAccuracy 3.9 4.11 -
locationReducedAccuracy x 4.11 -
microphoneAuthorized 3.9 4.11 -
notificationAuthorized 3.9 4.11 -
notificationAlertAuthorized x 4.11 -
notificationBadgeAuthorized x 4.11 -
notificationSoundAuthorized x 4.11 -

# getAppAuthorizeSetting 兼容性

Android iOS web
3.9 4.11 x

# 参见

相关 Bug

# 示例

hello uni-app x

<template>
 <page-head :title="title"></page-head>
 <view class="uni-common-mt">
   <view class="uni-list">
     <!-- #ifdef APP-IOS -->
     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否授权使用相册</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="albumAuthorized" />
       </view>
     </view>
     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否授权使用蓝牙</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="bluetoothAuthorized" />
       </view>
     </view>
      <!-- #endif -->
     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否授权使用摄像头</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="cameraAuthorized" />
       </view>
     </view>
     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否授权使用定位</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="locationAuthorized" />
       </view>
     </view>
     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">定位准确度</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="locationAccuracy" />
       </view>
     </view>
     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否授权使用麦克风</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="microphoneAuthorized" />
       </view>
     </view>

     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否授权通知</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="notificationAuthorized" />
       </view>
     </view>
<!-- #ifdef APP-IOS -->
     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否允许通知带有提醒</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="notificationAlertAuthorized" />
       </view>
     </view>

     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否允许通知带有标记</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="notificationBadgeAuthorized" />
       </view>
     </view>
     <view class="uni-list-cell">
       <view class="uni-pd">
         <view class="uni-label" style="width:180px;">是否允许通知带有声音</view>
       </view>
       <view class="uni-list-cell-db">
         <input type="text" :disabled="true" placeholder="未获取" :value="notificationSoundAuthorized" />
       </view>
     </view>
<!-- #endif -->
   </view>
   <view class="uni-padding-wrap">
     <view class="uni-btn-v">
       <button type="primary" @tap="getAppAuthorizeSetting">获取App授权设置</button>
     </view>
   </view>
 </view>
</template>
<script>
 export default {
   data() {
     return {
       title: 'getAppAuthorizeSetting',
       cameraAuthorized: "",
       albumAuthorized: "",
       locationAuthorized: "",
       locationAccuracy: "",
       microphoneAuthorized: "",
       bluetoothAuthorized: "",
       notificationAuthorized: "",
       notificationAlertAuthorized: "",
       notificationBadgeAuthorized: "",
       notificationSoundAuthorized: ""
     }
   },
   onUnload: function () {
   },
   methods: {
     getAppAuthorizeSetting: function () {
       const res = uni.getAppAuthorizeSetting();
       this.cameraAuthorized = res.cameraAuthorized;
       this.locationAuthorized = res.locationAuthorized;
       this.locationAccuracy = res.locationAccuracy ?? "unsupported";
       this.microphoneAuthorized = res.microphoneAuthorized;
       this.notificationAuthorized = res.notificationAuthorized;
       // #ifdef APP-IOS
       this.notificationAlertAuthorized = res.notificationAlertAuthorized;
       this.notificationBadgeAuthorized = res.notificationBadgeAuthorized;
       this.notificationSoundAuthorized = res.notificationSoundAuthorized;
       this.bluetoothAuthorized = res.bluetoothAuthorized;
       this.albumAuthorized = res.albumAuthorized;
       // #endif

     }
   }
 }
</script>

<style>
 .uni-pd {
   padding-left: 15px;
 }
</style>

# 通用类型

# GeneralCallbackResult

名称 类型 必备 默认值 描述
errMsg string - 错误信息