全部产品
Search
文档中心

SuperApp:wv.getSetting

更新时间:Feb 17, 2025

获取用户对当前小程序的授权状态,并与wv.authorize接口搭配使用。

入参

Object类型,参数如下:

参数

类型

必填

描述

success

Function

查询成功的回调函数。

fail

Function

查询失败的回调函数。

出参

success回调函数会收到一个Object类型的对象,其中key为scope值,value为Boolean值,表示用户是否允许授权,其属性如下:

属性

类型

描述

authSetting

Object

用户授权结果,其中key为scope值,value为Boolean值,表示用户是否允许授权。

authSetting属性描述如下:

属性

类型

描述

location

Boolean

地理位置:未授权返回false,对应接口: WVLocation.getLocation;WVLocation.searchLocation

camera

Boolean

摄像头:未授权返回false,对应接口:WVScan.scan

bluetooth

Boolean

蓝牙:未授权返回false,对应接口:WVBluetooth涉及所有方法

album

Boolean

相册:未授权返回false,对应接口:WVVideo.chooseVideo;WVCamera.takePhoto

contacts

Boolean

通讯录:未授权返回false,对应接口:WVContacts涉及所有方法

microphone

Boolean

麦克风:未授权返回false,对应接口:WVMotion.listenBlow;WVMotion.stopListenBlow

file

Boolean

文件:未授权返回false,对应接口:WVFile涉及所有方法 WVVideo.saveVideoToPhotosAlbum;WVImage.saveImage

call

Boolean

打电话:未授权返回false,对应接口:WVCall.dial;WVCall.call

vibrate

Boolean

震动:未授权返回false,对应接口:WVMotion.vibrate

screen

Boolean

截屏:未授权返回false,对应接口:WVScreenCapture.capture

fail回调函数会收到一个Object类型的对象,msg为错误信息:

错误信息

错误说明

解决方案

You need to configure the authorization switch to apply for authorization

需要打开授权开关

检查容器初始化是否配置授权开关。

User not bound

容器注册用户信息UserId未注册

检查容器注册用户信息,userId是否传入。

示例代码

window.WindVane.call('wv', 'getSetting', {}, function(res) {
    const { camera = false, location = false } = res.authSetting;
}, function(e) {
    alert('failure:' + JSON.stringify(e));
});