Ranging multiplt ibeacon regions

231 Views Asked by At

Iam using react-native-beacons-manager library in react native to discover ibeacon beacons, but when I add two const region1 and const region2 and then use Beacons.startRangingBeaconsInRegion(region1) and Beacons.startRangingBeaconsInRegion(region2) it does not return anything.

The code I've used is

componentWillMount() {
    Beacons.requestWhenInUseAuthorization();
    const region = {
      identifier: '973d0a2cf8f07443acdc71fad3df043d',
      uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D',
      major: 1,
      minor: 2
    };
    const region2 = {
      identifier: '39120dc19aa1a49c16b48bc4a5ea300b',
      uuid: '5627DB35-B8A3-4EDC-987C-462CCB3B034F',
      major: 2,
      minor: 1
    }
    // Range for beacons inside the region
    Beacons.startRangingBeaconsInRegion(region);
    Beacons.startRangingBeaconsInRegion(region2);
    Beacons.startUpdatingLocation();
  }

  componentDidMount() {
    // Ranging: Listen for beacon changes
    this.beaconsDidRange = DeviceEventEmitter.addListener(
      'beaconsDidRange',
      (data) => {
        this.setState({
          dataSource: this.state.dataSource.cloneWithRows(data.beacons)
        });
      }
    );
    const UniqueID = DeviceInfo.getUniqueID();


  }

  componentWillUnMount() {
    this.beaconsDidRange = null;
  }
0

There are 0 best solutions below