react-native-beacons-manager icon indicating copy to clipboard operation
react-native-beacons-manager copied to clipboard

No beacons detected when ranging and phone locked Android

Open 27comar opened this issue 6 years ago • 10 comments

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.

27comar avatar Jul 05 '19 09:07 27comar

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.

divye11 avatar Jul 30 '19 07:07 divye11

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

chentianci123 avatar Nov 08 '19 09:11 chentianci123

@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.

sfreeman28 avatar Dec 03 '19 02:12 sfreeman28

@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

chentianci123 avatar Dec 03 '19 02:12 chentianci123

@chentianci123 I am using version 0.59.10 of react-native

sfreeman28 avatar Dec 03 '19 19:12 sfreeman28

@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

chentianci123 avatar Dec 04 '19 01:12 chentianci123

@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 :)

27comar avatar Jun 03 '20 08:06 27comar

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

sfreeman28 avatar Jun 03 '20 21:06 sfreeman28

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

sfreeman28 avatar Jun 04 '20 20:06 sfreeman28

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 !

27comar avatar Jun 05 '20 14:06 27comar