Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error : App not detecting bluetooth on Android 12 #240

Open
anhquanngo opened this issue May 31, 2022 · 4 comments
Open

Error : App not detecting bluetooth on Android 12 #240

anhquanngo opened this issue May 31, 2022 · 4 comments

Comments

@anhquanngo
Copy link

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

@Jake-Young
Copy link

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: #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!

@mattia-beta
Copy link

It's working!

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

@sangheraajit
Copy link

Hi @mattia-beta

Do you have working code in android?

@interstates21
Copy link

interstates21 commented Sep 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants