打开小程序就提示蓝牙初始化失败,但是在开发版本和体验版本上没有这个问题
wx.getSetting({
success:(res)=>{
if(res.authSetting['scope.bluetooth'] != undefined && res.authSetting['scope.bluetooth'] == false){
wx.openSetting({
success:(authData)=>{
if(authData.authSetting['scope.bluetooth'] == true){
this.openBluetoothAdapter() ;
}else{
wx.showToast({
title: '未获得蓝牙使用权限!',
icon: "none"
})
}
}
})
}
if(res.authSetting['scope.bluetooth'] == undefined){
wx.authorize({
scope: 'scope.bluetooth',
success:(res)=>{
this.openBluetoothAdapter() ;
}
})
}
if(res.authSetting['scope.bluetooth'] == true){
this.openBluetoothAdapter() ;
}
}
})
openBluetoothAdapter(){
if(this.globalData.blehaveInit == false){
wx.showLoading({title: "正在初始化蓝牙..."});
}
wx.openBluetoothAdapter({
success: (res) => {
console.log('openBluetoothAdapter success', res)
this.globalData.blehaveInit = true;
wx.hideLoading();
},
fail: (res) => {
if (res.errCode === 10001) {
wx.onBluetoothAdapterStateChange(function (res) {
console.log('onBluetoothAdapterStateChange', res)
if (res.available) {
this.globalData.blehaveInit = true;
wx.hideLoading();
}else{
this.globalData.blehaveInit = false;
wx.hideLoading();
wx.showToast({
title: '蓝牙初始化失败!',
icon: "none"
})
}
})
}else{
this.globalData.blehaveInit = false;
wx.hideLoading();
wx.showToast({
title: '蓝牙初始化失败!',
icon: "none"
})
}
}
})
},
以上是蓝牙的授权和初始化代码,在编译器里面也有警告无效的 app.json permission["scope.bluetooth"],请问如何解决?

完善一下用户隐私协议,加上“访问你的蓝牙”选项,发版勾选“采集用户隐私”