MacKentoch / react-native-beacons-manager

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

No beacons detected when ranging and phone locked Android #141

Open 27comar opened 5 years ago

27comar commented 5 years ago

Version

1.0.7

Platform

Android

OS version

Android 8.1.0

Steps to reproduce

  1. Start beacon ranging
  2. Lock the device

Expected behavior

The beacons around should be visible in the array of the 'beaconsDidRange' event, like when the app is in foreground.

Actual behavior

The 'beaconsDidRange' event is triggered each second, but the array of beacons around is empty.

When the app is in foreground or background but the phone is unlocked, the ranging works correctly. The only problem is when the phone is locked. I only have access to a 8.1.0 Android device, so I couldn't test with other versions.

divye11 commented 5 years ago

I suppose Android Oreo has put forth execution limits in the background, as well as when the app is killed. In order to continuously(regardless of the state) detect beacons, you need a foreground service. Which device are you using? Share the logs from Android Studio, that could show when detection was stopped.

chentianci123 commented 4 years ago

我遇到了同样的问题,请问您解决了吗

sfreeman28 commented 4 years ago

@27comar Hey did you get any further with this issue? I am witnessing the same thing on my Android phone.

I don't see any foreground service being managed in the library's android code.

chentianci123 commented 4 years ago

@27comar Hey did you get any further with this issue? I am witnessing the same thing on my Android phone.

I don't see any foreground service being managed in the library's android code.

I encountered the same problem before, you try to modify the version of react-native

sfreeman28 commented 4 years ago

@chentianci123 I am using version 0.59.10 of react-native

chentianci123 commented 4 years ago

@chentianci123 I am using version 0.59.10 of react-native

You changed the react-native version of react-native-beacons-manager to be the same as your version, or integrated the source code of this plugin directly into your existing project

27comar commented 4 years ago

@sfreeman28 @chentianci123 I'm really sorry, I wasn't active on my GitHub account until now. I was able to resolve the problem by changing the dependency of the beacon library that is used by this library. I will explain in case you still need it.

In fact, in the react-native-beacons-manager/android/build.gradle file, I replaced the line 32 (at the time of my project it was line 32, maybe it has changed) with : compile 'org.altbeacon:android-beacon-library:2.13.1' (I think it must be equal or greater than 2.13.1, at the time I used it in August 2019 it worked with 2.13.1).

Hope this helps :)

sfreeman28 commented 4 years ago

Thank you @27comar! Yes this solves the issue, thanks for the reply =]

sfreeman28 commented 4 years ago

Hi @27comar was just wondering if you also encountered issues with iOS in your app? My issue is described here https://github.com/MacKentoch/react-native-beacons-manager/issues/189.

I know it's not on Android but its similar in that both issues are related to backgrounding the application. Thanks

27comar commented 4 years ago

Hi @27comar was just wondering if you also encountered issues with iOS in your app? My issue is described here #189.

I know it's not on Android but its similar in that both issues are related to backgrounding the application. Thanks

Hi @sfreeman28, I'm happy I could help you ! I also encountered your problem on iOS and answered to you in your other issue, here. Hope this helps too !