uni.startBluetoothDevicesDiscovery({
complete (e) {
console.log(e)
if (e.errMsg == "startBluetoothDevicesDiscovery:ok") {
uni.onBluetoothDeviceFound(devices => {
console.log(devices)
if(!_this.devices.length) return _this.devices.push(devices.devices[0])
let index = 0
let state = true
_this.devices.forEach((key, i) => {
if(key.deviceId == devices.devices[0].deviceId) {
state = false
index = i
}
})
if(state) {
_this.devices.push(devices.devices[0])
} else {
_this.devices[index] = devices.devices[0]
}
})
}
}
})
1,iOS系统能正常执行回调 (iPhone 13,iPhone 11)
2,鸿蒙系统也能正常执行回调 (荣耀 X10)
3,部分安卓手机无法执行回调 (小米 12s Ultra)
小米 12s Ultre 又可以连接了,是因为app授权的问题,将app授权改为“使用时允许”就可以正常查询了