image.png
以下两个方法都会获取蓝牙权限(推荐第一个获取蓝牙权限,第二个主要是判断蓝牙是否打开)
方法一:
wx.authorize({
scope: 'scope.bluetooth',
success() { //蓝牙已授权
console.log('蓝牙---已授权');
},
fail() { //蓝牙未授权
console.log('蓝牙---未授权');
}
})
方法二:
wx.openBluetoothAdapter({
success: (res) => {
console.log('蓝牙状态---开启');
},
fail: (err) => {
console.log('蓝牙状态---关闭');
}
})