在没有勾选 v3 编译的时候,真机运行就可以扫描到ibeacon设备
但选择v3 编译后,就识别不到ibeacon ,onBeaconUpdate方法不进去
async function openBluetoothAdapter (onError) {
// 微信内浏览器直接认为打开
if (env.isWXWV) return isOpen = true
const data = await uni.openBluetoothAdapter({})
const [err, res] = data
if (err) return onError(err)
isOpen = true
console.log(`开启蓝牙模块`)
return res
}
async function closeBluetoothAdapter (OBJECT) {
await uni.closeBluetoothAdapter({})
console.log(`关闭蓝牙模块`)
isOpen = false
}
async function startBeaconDiscovery (uuids, onError) {
if (env.isWXWV) {
wx.startSearchBeacons({
ticket: '',
complete: function (argv) {
isStarted = true
}
})
} else {
const data = await uni.startBeaconDiscovery({ uuids })
const [err, res] = data
if (err) return onError(err)
isStarted = true
console.log(`开启ibeacon扫描`)
}
}
0 个回复