alann-maulana / flutter_beacon

An hybrid iBeacon scanner and transmitter SDK for Flutter Android and iOS.
Apache License 2.0
116 stars 142 forks source link

BUGS IOS cannot complete scanning in second try #108

Open eggyot opened 2 years ago

eggyot commented 2 years ago

I try to find beacon and in first try to scanning it's work normal. after found beacon and I try to scanning again with same function, it's cannot complete and whenComplete is never execute

ADD NOTE maybe because permission in ios cannot run twice like this post? https://github.com/Baseflow/flutter-permission-handler/issues/752

List<Region> regions;
        flutterBeacon.initializeAndCheckScanning.whenComplete(() {
          regions = <Region>[];
          if (Platform.isIOS) {
            // iOS platform, at least set identifier and proximityUUID for region scanning
            regions.add(
                Region(identifier: 'BEACON', proximityUUID: proximityUUID));
          } else {
            // android platform, it can ranging out of beacon that filter all of Proximity UUID
            regions.add(Region(identifier: 'com.beacon'));
          }

          // to start ranging beacons
          _streamRanging =
              flutterBeacon.ranging(regions).listen((RangingResult result) {
            // result contains a region and list of beacons found
            // list can be empty if no matching beacons were found in range
            for (var element in result.beacons) {
              i++;
              print("minor:" +
                  element.minor.toString() +
                  ", major:" +
                  element.major.toString() +
                  ", proximityUUID:" +
                  element.proximityUUID.toString());
              if (element.proximityUUID.toString() == proximityUUID &&
                  element.major.toString() == major &&
                  element.minor.toString() == minor) {
                eventAbsen(eventId, eventName, locationName, uuid, wajibBeacon,
                    eventImages, imei);
                break;
                // flutterBeacon.ranging(regions).cancel();
              } else if (i > result.beacons.length) {
                beaconNotFound(index);
                break;
              }
            }
          });
        })
mokhles404 commented 1 year ago

Did you find any solution?

eggyot commented 1 year ago

nope

raj457036 commented 1 year ago
  1. call await flutterBeacon.initializeAndCheckScanning; once anywhere before calling any other method. ( To initialize the LocationManager)
  2. Use PR #118 for now. ( Fixes the [CoreBluetooth] XPC connection invalid )
devberkay commented 1 year ago

any update?