授权API
ty.authorize
权限请求方法
需引入
BaseKit
,且在>=1.2.10
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
scope | string |
是 | scope 权限名称 举例子: scope.bluetooth 蓝牙权限 scope.writePhotosAlbum 写入相册权限 scope.userLocationBackground 后台定位权限 scope.record 麦克风权限 scope.camera 摄像头权限 scope.userLocation 低精度定位权限 scope.userPreciseLocation 高精度定位权限 | |
complete | function |
否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function |
否 | 接口调用成功的回调函数 | |
fail | function |
否 | 接口调用失败的回调函数 |
函数定义示例
/**
* 权限请求方法
*/
export function authorize(params: {
/**
* scope 权限名称
* 举例子:
* scope.bluetooth 蓝牙权限
* scope.writePhotosAlbum 写入相册权限
* scope.userLocationBackground 后台定位权限
* scope.record 麦克风权限
* scope.camera 摄像头权限
* scope.userLocation 低精度定位权限
* scope.userPreciseLocation 高精度定位权限
*/
scope: string;
complete?: () => void;
success?: (params: null) => void;
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
ty.authorizeStatus
查询权限状态
需引入
BaseKit
,且在>=1.2.10
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
scope | string |
是 | scope 权限名称 举例子: scope.bluetooth 蓝牙权限 scope.writePhotosAlbum 写入相册权限 scope.userLocationBackground 后台定位权限 scope.record 麦克风权限 scope.camera 摄像头权限 scope.userLocation 低精度定位权限 scope.userPreciseLocation 高精度定位权限 | |
complete | function |
否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function |
否 | 接口调用成功的回调函数 | |
fail | function |
否 | 接口调用失败的回调函数 |
函数定义示例
/**
* 查询权限状态
*/
export function authorizeStatus(param