Driversnote-Dev / react-native-kontaktio

React Native (iOS and Android) library for Kontakt.io beacons (and all other beacons)
MIT License
112 stars 48 forks source link

stop scanning #55

Closed callmejm closed 5 years ago

callmejm commented 5 years ago

I bought few iBeacon online and tried your example, yes it detect all the beacons. However, it did not keep scanning until I want to stop, it stop itself , I put a counter in beaconsDidUpdate it stop increase until 20+ to 30+ only, and each increment need about 4s, how to set to 1s.

let counter = 0;
componentDidMount() {
    connect()
      .then(() => startScanning())
      .catch(error => console.log('error', error));

    DeviceEventEmitter.addListener(
      'beaconsDidUpdate',
      ({ beacons, region }) => {
        counter++;
        console.log('Last scan ' + moment().format('h:mm:ss a'));
        console.log('beaconsDidUpdate', beacons, region, counter);
      },
    );
  }