uni.getLocation({
type: 'wgs84',
geocode: true,
success: (res) => {
uni.openBluetoothAdapter({
success:() => {
uni.startBluetoothDevicesDiscovery({
success: (res) => {
// const appAuthorizeSetting = uni.getAppAuthorizeSetting()
// uni.$u.toast('appAuthorizeSetting ====》 ' + appAuthorizeSetting.bluetoothAuthorized)
const systemSetting = uni.getSystemSetting()
uni.$u.toast('systemSetting ====》 ' + systemSetting.bluetoothEnabled + '=== ' + systemSetting.bluetoothError)
uni.onBluetoothDeviceFound(device => {
// uni.$u.toast('onBluetoothDeviceFound device==>' + JSON.stringify(device))
console.log(device,'device');
})
}
})
},
})
},
})

- 发布:2023-05-29 17:28
- 更新:2023-05-29 17:44
- 阅读:370
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 13.0
HBuilderX类型: 正式
HBuilderX版本号: 3.8.3
手机系统: iOS
手机系统版本号: iOS 16
手机厂商: 苹果
手机机型: iphone11,iphonese2
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
uni.getLocation({
type: 'wgs84',
geocode: true,
success: (res) => {
uni.openBluetoothAdapter({
success:() => {
uni.startBluetoothDevicesDiscovery({
success: (res) => {
// const appAuthorizeSetting = uni.getAppAuthorizeSetting()
// uni.$u.toast('appAuthorizeSetting ====》 ' + appAuthorizeSetting.bluetoothAuthorized)
const systemSetting = uni.getSystemSetting()
uni.$u.toast('systemSetting ====》 ' + systemSetting.bluetoothEnabled + '=== ' + systemSetting.bluetoothError)
uni.onBluetoothDeviceFound(device => {
// uni.$u.toast('onBluetoothDeviceFound device==>' + JSON.stringify(device))
console.log(device,'device');
})
}
})
},
})
},
})
uni.getLocation({
type: 'wgs84',
geocode: true,
success: (res) => {
uni.openBluetoothAdapter({
success:() => {
uni.startBluetoothDevicesDiscovery({
success: (res) => {
// const appAuthorizeSetting = uni.getAppAuthorizeSetting()
// uni.$u.toast('appAuthorizeSetting ====》 ' + appAuthorizeSetting.bluetoothAuthorized)
const systemSetting = uni.getSystemSetting()
uni.$u.toast('systemSetting ====》 ' + systemSetting.bluetoothEnabled + '=== ' + systemSetting.bluetoothError)
uni.onBluetoothDeviceFound(device => {
// uni.$u.toast('onBluetoothDeviceFound device==>' + JSON.stringify(device))
console.log(device,'device');
})
}
})
},
})
},
})
预期结果:
预期结果能够搜索到device设备
预期结果能够搜索到device设备
实际结果:
实际结果并没有搜到device设备
实际结果并没有搜到device设备
bug描述:
打 ipa 包到手机上安装,使用 onBluetoothDeviceFound api 搜索不到 device 设备。数据线连接电脑使用自定义基座可以搜索到 device 设备,另外 android 端 自定义基座 及 安装到手机调试都是正常的。
7***@qq.com (作者)
你好,请问在哪里检查? 我这边目前手机设置的蓝牙权限是打开的,另外项目下的蓝牙模块也是勾选的,以及getAppAuthorizeSetting和systemSetting打印显示都是有权限的。是还有其他地方可以配置权限的吗?
2023-05-29 18:35
DCloud_iOS_WZT
回复 7***@qq.com: 那应该不是权限问题,你这边搜索不到设备是指搜索不到某一台设备 还是所有的都搜不到
2023-05-29 19:35
7***@qq.com (作者)
回复 DCloud_iOS_WZT: 是所有的都搜索不到,但是连数据线自定义基座调试的时候是可以正常搜索的
2023-05-29 22:15
DCloud_iOS_WZT
回复 7***@qq.com: 提供一个简单的示例工程吧 我这边测试没复现问题
2023-05-30 12:07
7***@qq.com (作者)
回复 DCloud_iOS_WZT: 谢谢,在写简单示例工程的过程中找到原因了。ios 打包不可以使用快速安心打包,因为自定义基座是强制使用传统打包的,所以一直没出问题。
2023-05-30 15:40
DCloud_iOS_WZT
回复 7***@qq.com: 安心打包理论上也可以的 你是用的mac还是windows
2023-05-31 11:21