/** * m-permission-manager 跨平台权限管理接口 */ /** 统一权限标识,三端通用 */ export type PermissionKey = | 'camera' | 'photoLibrary' | 'storage' | 'readStorage' | 'location' | 'coarseLocation' | 'microphone' | 'contacts' | 'writeContacts' | 'bluetooth' | 'phone' | 'phoneState' | 'sms' | 'readSms' | 'receiveSms' | 'overlay' | 'writeSettings' export type PermissionStatus = | 'granted' | 'denied' | 'notDetermined' | 'restricted' | 'unsupported' export type PermissionCheckResult = { permission : PermissionKey status : PermissionStatus granted : boolean } export type PermissionGrantResult = { permission : PermissionKey status : PermissionStatus granted : boolean } export type CheckPermissionsResult = { results : PermissionCheckResult[] allGranted : boolean } export type RequestPermissionsResult = { results : PermissionGrantResult[] allGranted : boolean } export type CheckPermissionOptions = { permission : PermissionKey success ?: (res : PermissionCheckResult) => void fail ?: (res : PermissionFail) => void complete ?: (res : any) => void } export type CheckPermissionsOptions = { permissions : PermissionKey[] success ?: (res : CheckPermissionsResult) => void fail ?: (res : PermissionFail) => void complete ?: (res : any) => void } export type RequestPermissionOptions = { permission : PermissionKey success ?: (res : PermissionGrantResult) => void fail ?: (res : PermissionFail) => void complete ?: (res : any) => void } export type RequestPermissionsOptions = { permissions : PermissionKey[] success ?: (res : RequestPermissionsResult) => void fail ?: (res : PermissionFail) => void complete ?: (res : any) => void } export type OpenAppSettingsOptions = { /** 指定权限类型,各端将尽量跳转到对应设置页 */ permission ?: PermissionKey success ?: (res : PermissionCheckResult) => void fail ?: (res : PermissionFail) => void complete ?: (res : any) => void } export type GetSupportedPermissionsResult = { permissions : PermissionKey[] } /** * 9020001 当前环境不支持 * 9020002 用户拒绝授权 * 9020003 权限不支持当前平台 * 9020004 打开系统设置失败 * 9020005 权限检查失败 * 9020006 权限申请失败 */ export type PermissionErrorCode = 9020001 | 9020002 | 9020003 | 9020004 | 9020005 | 9020006 export interface PermissionFail extends IUniError { errCode : PermissionErrorCode } export type CheckPermissionSync = (permission : PermissionKey) => PermissionCheckResult export type CheckPermissionsSync = (permissions : PermissionKey[]) => CheckPermissionsResult export type CheckPermission = (options : CheckPermissionOptions) => void export type CheckPermissions = (options : CheckPermissionsOptions) => void export type RequestPermission = (options : RequestPermissionOptions) => void export type RequestPermissions = (options : RequestPermissionsOptions) => void export type OpenAppSettings = (options : OpenAppSettingsOptions) => void export type GetSupportedPermissionsSync = () => GetSupportedPermissionsResult /** 蓝牙演示信息(读取系统蓝牙开关状态) */ export type BluetoothDemoInfo = { available : boolean enabled : boolean stateText : string stateCode : number } export type GetBluetoothDemoInfoSync = () => BluetoothDemoInfo