# uni.getAppAuthorizeSetting()

Get APP authorization settings

Platform Difference Description

App H5 微信小程序 支付宝小程序 百度小程序 抖音小程序、飞书小程序 钉钉小程序 QQ小程序 快手小程序 京东小程序 元服务
HBuilderX (3.5.2+) x 基础库 (2.20.1+) x x x x x x x x

# getAppAuthorizeSetting 兼容性

HarmonyOS
HBuilderX 4.31

Return parameter description

Properties Type Description Platform Difference Description
albumAuthorized 'authorized'/'denied'/'not determined' Album switch Album only iOS support
bluetoothAuthorized 'authorized'/'denied'/'not determined'/'config error' The switch that allows the use of Bluetooth App only supports iOS
cameraAuthorized 'authorized'/'denied'/'not determined'/'config error' Switch to allow camera use
locationAuthorized 'authorized'/'denied'/'not determined'/'config error' Located switch allowed
locationAccuracy String Location accuracy. "reduced" means fuzzy positioning; "full" means precise positioning; "unsupported" means not supported Only iOS supports on the App side
microphoneAuthorized 'authorized'/'denied'/'not determined'/'config error' Switch to allow microphone use
notificationAuthorized 'authorized'/'denied'/'not determined'/'config error' Allow notification switch
notificationAlertAuthorized 'authorized'/'denied'/'not determined'/'config error' Allow notification switch with reminder App side only supported by iOS (10.0+)
notificationBadgeAuthorized 'authorized'/'denied'/'not determined'/'config error' Allow notification of flagged switches App-side only supported on iOS (10.0+)
notificationSoundAuthorized 'authorized'/'denied'/'not determined'/'config error' Allow notifications with sound switch App side only supported by iOS (10.0+)
phoneCalendarAuthorized 'authorized'/'denied'/'not determined' The switch that allows reading and writing the calendar Not supported on the App side

# 返回值

类型
GetAppAuthorizeSettingResult

|:-|:-|:-|:-|:-:|:-| |albumAuthorized|string|是|-|

-
|允许 App 使用相册的开关
| |bluetoothAuthorized|string|是|-|
-
|允许 App 使用蓝牙的开关
| |cameraAuthorized|string|是|-|
-
|允许 App 使用摄像头的开关
| |locationAuthorized|string|是|-|
-
|允许 App 使用定位的开关
| |locationAccuracy|string|否|-|
-
|定位准确度。
| |locationReducedAccuracy|boolean|否|-|
-
|定位准确度(推荐使用 locationAccuracy 属性)。true 表示模糊定位,false 表示精确定位(仅 iOS 支持)| |microphoneAuthorized|string|是|-|
-
|允许 App 使用麦克风的开关
| |notificationAuthorized|string|是|-|
-
|允许 App 通知的开关
| |notificationAlertAuthorized|string|否|-|
-
|允许 App 通知带有提醒的开关(仅 iOS 支持)
| |notificationBadgeAuthorized|string|否|-|
-
|允许 App 通知带有标记的开关(仅 iOS 支持)
| |notificationSoundAuthorized|string|否|-|
-
|允许 App 通知带有声音的开关(仅 iOS 支持)
| |phoneCalendarAuthorized|string|否|-|
|允许读写日历的开关(仅微信小程序支持)
| |readPhoneCalendarAuthorized|string|否|-|
|允许读日历的开关(仅鸿蒙支持)
| |writePhoneCalendarAuthorized|string|否|-|
|允许写日历的开关(仅鸿蒙支持)
| |pasteboardAuthorized|string|否|-|
|允许读取剪切版(仅鸿蒙支持)
|

If the App needs to obtain more permission status, please refer to the plugin: App Permission Judgment and Tips

# 不推荐使用的返回参数,仅为兼容保留

|locationReducedAccuracy|boolean|Ambiguous location. true means fuzzy positioning, false means precise positioning |App only supports iOS|

Tips:

  • 'authorized': indicates that authorization has been obtained, and there is no need to request authorization again;
  • 'denied': Indicates that the request for authorization has been rejected and cannot be requested for authorization again; (in this case, the user needs to be guided to open the system settings and open the permissions in the settings page)
  • 'not determined': Indicates that authorization has not been requested, and will be requested the next time the App calls the corresponding permission of the system; (only iOS will appear. In this case, guide the user to open the system settings, and do not display the switch)
  • 'config error': only returned on the App side
    • bluetoothAuthorized:
      • Android platform will not return config error
      • iOS platform: indicates that the BlueTooth (Bluetooth Low Energy) module is not configured in manifest.json -> App module configuration
    • cameraAuthorized:
      • Android platform: indicates that the android.permission.CAMERA permission is not granted
      • iOS platform will not return config error
    • locationAuthorized:
      • Android platform: indicates that the android.permission.ACCESS_COARSE_LOCATION permission is not granted
      • iOS platform: indicates that the Geolocation (location) module is not configured in manifest.json -> App module configuration
    • microphoneAuthorized:
      • Android platform: indicates that the android.permission.RECORD_AUDIO permission is not granted
      • iOS platform will not return config error
    • notificationAuthorized、notificationAlertAuthorized、notificationBadgeAuthorized、notificationSoundAuthorized:
      • Android platform not supported
      • iOS platform: Indicates that the Push' module is not configured in manifest.json -> App module configuration`

Example

const appAuthorizeSetting = uni.getAppAuthorizeSetting()

console.log(appAuthorizeSetting.albumAuthorized)
console.log(appAuthorizeSetting.bluetoothAuthorized)
console.log(appAuthorizeSetting.cameraAuthorized)
console.log(appAuthorizeSetting.locationAuthorized)
console.log(appAuthorizeSetting.locationReducedAccuracy)
console.log(appAuthorizeSetting.microphoneAuthorized)
console.log(appAuthorizeSetting.notificationAlertAuthorized)
console.log(appAuthorizeSetting.notificationAuthorized)
console.log(appAuthorizeSetting.notificationBadgeAuthorized)
console.log(appAuthorizeSetting.notificationSoundAuthorized)
console.log(appAuthorizeSetting.phoneCalendarAuthorized)