繁体   English   中英

Flutter IOS 信标无法使用区域和 UUID 设置进行扫描

[英]Flutter IOS beacon not able to scan with Region and UUID settings

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

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());
        });
      }
    });
  }

需要检查的几件事:

  • 确保您的区域定义具有proximityUUID 值。 我很惊讶它甚至可以在没有这个的 Android 上工作。 在 iOS 上,它肯定根本不起作用——iOS 需要预先指定信标接近 UUID 以便检测。 您为 prximityUUID 提供的值必须与您的信标所宣传的内容完全匹配,否则您将看不到它。

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

  • 请特别确保您已授予 iOS 应用程序的位置权限。 您可以 go 到 Settings -> Your App Name 以检查是否授予位置权限。

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

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

https://pub.dev/packages/flutter_beacon

GitHub 有更新,但之前尚未推送到 pub.dev。 更新到 0.5.0。

始终检查 pub.dev 以获取更新。 或 github 报告了问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM