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

Error : App not detecting bluetooth on Android 12

Open anhquanngo opened this issue 2 years ago • 4 comments

Version

1.0.7

Platform

Android

OS version

android 12.0...

Steps to reproduce

Use device with andrioid 12 Beacons do not appear in beaconDidRange event Expected behavior Beacons should be detected

Expected behavior

Beacons detected in all cases

Actual behavior

Beacons are not detecting in any case

anhquanngo avatar May 31 '22 02:05 anhquanngo

We recently ran into the same problem when building for Android 12 and above, given that Google are now expecting every new app to target Android 12 (31+). A number of things need changed to get this to work.

NOTE - These changes have only been tested on our side for ranging with iBeacons.

Now instead of BLUETOOTH and BLUETOOTH_ADMIN we now only need BLUETOOTH_SCAN.

So your permission for Bluetooth in you Android Manifest should look like:

<!-- Replace both of these -->
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<!--  -->

<!-- With this -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<!--  -->

NOTE - You also need to change the required permissions in manifest for this library to the above. Again you only need BLUETOOTH_SCAN in the library manifest.

If you aren't already you also need to ask for both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION.

See permissions changes here: Android 12 Changes

We have forked this library to maintain it for more recent versions of RN, Android and iOS.

Our Fork: Here

If you don't want to use our fork, simply just update the permissions as I have described above and update the Altbeacon version to 2.19.4 as done here: https://github.com/MacKentoch/react-native-beacons-manager/pull/237

We know our version of the library works for RN up to:

  "react": "18.0.0",
  "react-native": "0.69.7",

I hope this solves your problems!

Jake-Young avatar Nov 21 '22 09:11 Jake-Young

It's working!

  "react": "17.0.2",
  "react-native": "0.65.3",
compileSdkVersion = 33
targetSdkVersion = 32

mattia-beta avatar Jan 27 '23 10:01 mattia-beta

Hi @mattia-beta

Do you have working code in android?

sangheraajit avatar Mar 29 '23 10:03 sangheraajit

Worth to mention, BLUETOOTH_SCAN requires a runtime permission prompt. @Jake-Young's fork works perfectly in that case!

interstates21 avatar Sep 18 '23 23:09 interstates21