| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- /**
- * 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
|