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

我与影子孤独终老i 提交于 2020-04-30 06:25:26

问题


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

回答1:


A few things to check:

  • 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.

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

  • 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



来源:https://stackoverflow.com/questions/61442488/flutter-ios-beacon-not-able-to-scan-with-region-and-uuid-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!