MacKentoch / react-native-beacons-manager

React-Native library for detecting beacons (iOS and Android)
MIT License
579 stars 319 forks source link

Ranging iBeacons not detected. #63

Open konrad-marzec opened 6 years ago

konrad-marzec commented 6 years ago

Version

1.0.6

Platform

Android

OS version

android 7.1

Steps to reproduce

  1. I have installed demo app
    const subscription = DeviceEventEmitter.addListener(
    'beaconsDidRange',
    (data) => {
    console.log(data.beacons) - Array of all beacons inside a region
    }
    );

Expected behavior

beacons aarray should include my beacon

Actual behavior

beacons array is empty

MacKentoch commented 6 years ago

Hi,

It is an old version.

Is there any reason why you don't use v1.0.7 in your app?

I'm currently working on a HUGE (for Android) update with v1.1.0 in master branch. On Android, I can range multiple types of beacons (iBeacon, eddyStone...) - tested these days.

Please have a try with the master branch version just to be sure it does not come from something else.

oferRounds commented 6 years ago

@MacKentoch - is the new (Android) version suppose to include support for detection when the app is killed (https://github.com/Estimote/Android-SDK/issues/62#issuecomment-342522028)

johnlev commented 6 years ago

I am having the same problem (no beacons showing up for ranging) with Android. I have not tried on iOS, as my app is exclusively Android. I tried updating to the master branch version and experienced the crash on launch issue that other people have been having. More importantly I looked at the small amount of log I got before the crash and I noticed the exact same behavior as before: beaconsDidRange is being called, but no beacons despite the clear and measurable presence of beacons. I was also using 1.0.7, so I don't think it's a version issue.

What did seem curious is that, although I did apply an identifier to my ranging, the android log output seemed unaware of ids for the region: D/BeaconsAndroidModule: rangingConsumer didRangeBeaconsInRegion, region: id1: null id2: null id3: null That could be normal, but it would make sense that if no regions are ranging then no beacons would result. I also noticed: D/BluetoothLeScanner: could not find callback wrapper

For context, here is the code that I am using from start to finish (more or less):

import Beacons from 'react-native-beacons-manager';

const region = {
   uuid: '...',
   identifier: '1'
}

Beacons.detectIBeacons()

Beacons.startMonitoringForRegion(region).then(() => {
  console.log('Started monitoring', region);
}).catch((error) => {
  console.log('Failed to start monitoring!', error);
});

Beacons.startRangingBeaconsInRegion(region.identifier, region.uuid).then(() => {
   console.log('Started ranging');

  DeviceEventEmitter.addListener('beaconsDidRange', (data) => {
     console.log(data);
  });
}).catch((error) => {
  console.log('Failed to range');
  console.log(error);
});

For both monitoring and ranging it logs successfully starting both. For clarity I tried without a UUID for ranging as well, with the same result

Here are the permissions in the AndroidManifest.xml:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
johnlev commented 6 years ago

Update: I noticed that the monitoring does work, more or less, but I need ranging as well. If anyone has had this issue I would greatly appreciate knowing how you fixed it

anirom commented 5 years ago

@johnlev I have the same issue :(. Could you solve the problem?

bonkzero404 commented 5 years ago

Hi,

It is an old version.

Is there any reason why you don't use v1.0.7 in your app?

I'm currently working on a HUGE (for Android) update with v1.1.0 in master branch. On Android, I can range multiple types of beacons (iBeacon, eddyStone...) - tested these days.

Please have a try with the master branch version just to be sure it does not come from something else.

Hi @MacKentoch, i tried to install from branch master, but I got an error like this

whatsapp image 2018-09-20 at 8 27 01 pm

How to fixed it? Thanks

ycldz commented 1 year ago

+1