Flutter IOS信标无法使用Region和UUID设置进行扫描 [英] Flutter IOS beacon not able to scan with Region and UUID settings

查看:71
本文介绍了Flutter IOS信标无法使用Region和UUID设置进行扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,就是在颤抖中,我注意到无法操作或使用传统蓝牙,因为没有任何库支持它.我已经测试了flutter_blue-master等.因此,我看到它可以充当信标.所以我用下面的代码.对于android,我只需设置

I have this problem is that in flutter I notice there is not able to operate or use the traditional bluetooth as there is no any library supporting it. I have tested flutter_blue-master etc. So then I saw that it can behave as beacon. So I have used the codes below. For android I just set

Region(
      identifier: 'com.example.myDeviceRegion',)); its able to work. So the same I set in IOS its not able to work? So what is best workaround for blueetooth in flutter? I am using this package flutter_beacon. For the beacon broadcasting I am using this package beacon_broadcast.

initScanBeacon() async {
    await flutterBeacon.initializeScanning;
    await checkAllRequirements();
    if (!authorizationStatusOk ||
        !locationServiceEnabled ||
        !bluetoothEnabled) {
      print('RETURNED, authorizationStatusOk=$authorizationStatusOk, '
          'locationServiceEnabled=$locationServiceEnabled, '
          'bluetoothEnabled=$bluetoothEnabled');
      return;
    }
    /*final regions = <Region>[
      Region(
        identifier: 'com.example.myDeviceRegion',       
      ),
    ];*/
    final regions = <Region>[];
    regions.add(Region(
      identifier: 'com.example.myDeviceRegion',
      minor: 100,
      major: 1));

    if (_streamRanging != null) {
      if (_streamRanging.isPaused) {
        _streamRanging.resume();
        return;
      }
    }

    _streamRanging =
        flutterBeacon.monitoring(regions).listen((MonitoringResult result) {
      print(result);
      if (result != null && mounted) {
        print("GOT RESTULT READY");
        setState(() {
          //_regionBeacons[result.region] = result.region;
          _beacons.clear();
          print("List value is json"+result.toJson.toString());
          _regionBeacons.values.forEach((list) {
            print("List value is");
            _beacons.addAll(list);
            print("after Beacon size now is "+_beacons.length.toString());
          });
          //_beacons.sort(_compareParameters);
          print("Beacon size now is "+_beacons.length.toString());
        });
      }
    });
  }

推荐答案

要检查的几件事:

  • 确保您的Region定义具有接近UUID值.令我惊讶的是,没有它,它甚至可以在Android上运行.在iOS上,它肯定根本不起作用-iOS需要预先指定信标近距离UUID才能进行检测.您为prximityUUID提供的值必须与您的信标正在广告的内容完全匹配,否则您将看不到它.

  • Make sure your Region definition has a proximityUUID value. I am surprised that it works even on Android without this. On iOS it certainly won't work at all -- iOS requires a beacon proximityUUID be specified up front in order to detect. The value you give for the prximityUUID must exactly match what your beacon is advertising or you won't see it.

确保您已在此处完成所有iOS设置步骤: https://pub.dev/packages/flutter_beacon

Make sure you have gone through all the iOS setup steps here: https://pub.dev/packages/flutter_beacon

请务必确保已为iOS应用授予了位置权限.您可以转到设置"->您的应用名称"来检查是否授予了位置权限.

Be extra sure that you have granted location permission to your iOS app. You can go to Settings -> Your App Name to check if location permission is granted.

确保在手机设置中启用了蓝牙

Make sure bluetooth is enabled in settings for the phone

确保在手机设置中启用了位置

Make sure location is enabled in settings for the phone

这篇关于Flutter IOS信标无法使用Region和UUID设置进行扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆