以Promise风格调用: 支持
提前向用户发起授权请求
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
scope | string | 否 | 提前向用户发起授权请求 | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
值 | 说明 |
---|---|
scope.userInfo | 用户信息 |
scope.userLocation | 地理位置 |
scope.userLocationBackground | 后台定位 |
scope.writePhotosAlbum | 保存到相册 |
scope.camera | 摄像头 |
属性 | 类型 | 说明 |
---|---|---|
errMsg | string |
// 可以通过 xhs.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope xhs.getSetting({ success(res) { if (!res.authSetting['scope.record']) { xhs.authorize({ scope: 'scope.record', success () { // 用户已经同意小程序使用录音功能,后续调用 xhs.startRecord 接口不会弹窗询问 xhs.startRecord() } }) } } })