一直以来调用隐私接口时都需要使用wx.authorize()授权,比如 uni.getLocation()
// 获取授权
getAuthorize() {
const that = this;
uni.authorize({
scope: 'scope.userLocation', // 授权位置
success() {
that.getLocationInfo();
}
});
},
// 获取位置
getLocationInfo() {
const that = this;
uni.getLocation({
success: function(res) {
console.log('经度:' + res.longitude);
console.log('纬度:' + res.latitude);
that.myPosition.latitude = res.latitude;
that.myPosition.longitude = res.longitude;
that.powersLocation();
}
});
},
但是现在又出了个wx.onNeedPrivacyAuthorization()的《隐私保护》,那统一授权了之后是不是直接调用隐私接口就行?比如:
// 获取位置
getLocationInfo() {
const that = this;
uni.getLocation({
success: function(res) {
console.log('经度:' + res.longitude);
console.log('纬度:' + res.latitude);
that.myPosition.latitude = res.latitude;
that.myPosition.longitude = res.longitude;
that.powersLocation();
}
});
},
还需要在调用隐私接口前调用wx.authorize()单个询问授权吗?
参考管文