7***@qq.com
7***@qq.com
  • 发布:2024-03-12 15:38
  • 更新:2024-09-04 00:15
  • 阅读:204

【报Bug】IOS系统苹果12 13 调用蓝牙 uni.onBluetoothDeviceFound没有反应(安卓鸿蒙系统经测试都是好的 苹果15也是好的)

分类:uni-app

产品分类: uniapp/小程序

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 3.99

第三方开发者工具版本号: 3.8.11

基础库版本号: 1.14.2

项目创建方式: HBuilderX

示例代码:
    openBluetoothAdapter() {  
            console.log('开始搜索蓝牙设备')  
            uni.openBluetoothAdapter({  
                success: (res) => {  
                    this.startBluetoothDevicesDiscovery()  
                },  
                fail: (res) => {  
                    console.log('请打开设备蓝牙功能')  
                }  
            })  
        },  
        startBluetoothDevicesDiscovery() {  
            uni.startBluetoothDevicesDiscovery({  
                services: [], //搜索目标设备的服务  
                allowDuplicatesKey: false, //搜索结果是否允许重复  
                success: (res) => {  
                    this.onBluetoothDeviceFound()  
                },  
            })  
        },  
        onBluetoothDeviceFound() {  
            let devicesArr = []  
            uni.onBluetoothDeviceFound((res) => {  
                let devices = res.devices     
                devices.forEach((item) => {  
                    if (item.name) {  
                        devicesArr.push(item)  
                    }  
                })  
                this.devices = devicesArr  
            })  
        },

操作步骤:

小程序打开调用this.openBluetoothAdapter()

预期结果:

uni.onBluetoothDeviceFound调用成功 返回搜索到的设备

实际结果:

uni.onBluetoothDeviceFound 一直没有响应 也没有报错信息

bug描述:

IOS系统苹果12 13 调用蓝牙 uni.onBluetoothDeviceFound没有反应(安卓鸿蒙系统经测试都是好的 苹果15也是好的)

2024-03-12 15:38 负责人:无 分享
已邀请:
7***@qq.com

7***@qq.com (作者) - 90

补充:开发的是专有钉钉小程序。在小程序开发平台用官方的demo一样有这个问题

玄天枢

玄天枢

我做的app也遇到这个问题,onBluetoothDeviceFound无反应

oldRoad

oldRoad

startBluetoothDevicesDiscovery搜索去掉services参数就可以了

s***@163.com

s***@163.com

请问楼主这个问题 解决了么?

要回复问题请先登录注册