Closed Feffe01 closed 4 months ago
Hi @Feffe01 I did some research and it turns out that beacons won’t work on iOS with this library as it have different API. I’m not sure what’s happening with android 14, you might try https://github.com/Driversnote-Dev/react-native-kontaktio/issues/121#issuecomment-2098884380. Overall I would recommend moving to different library that focuses on beacons like react-native-beacons-manager or react-native-kontaktio
Thank you very much! This solved the problem.
For those having the same problem, the solution is modifying the permission of bluetooth scan like this:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" tools:remove="android:usesPermissionFlags" />
Because without it, android:usesPermissionFlags="neverForLocation"
is set causing some beacons not to be found.
In addition, if you have still problems, it's better to set:
import { BleManager, ScanMode } from 'react-native-ble-plx';
and { allowDuplicates: true, scanMode: ScanMode.LowLatency, }
to the settings of the scan. These allow to scan more beacons but with higher battery consumption.
Prerequisites
Expected Behavior
The app finds my ble beacon. When it is found the scan stops and gives a warning.
Current Behavior
The app doesn't find my ble beacon.
Library version
^3.2.0
Device
Android 14 and iOS 17.5.1
Environment info
Steps to reproduce
npx create-expo-app issue --template blank
;cd issue
;npm install react-native-ble-plx
;"plugins": ["react-native-ble-plx"]
;npx expo prebuild
;distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
todistributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
( I do this because I use Java 22.0.1 );npx expo run:android
ornpx expo run:ios --device --configuration Release
Formatted code sample or link to a repository
Relevant log output
Additional information
This app is a simple version of a component I've built on another app. In both apps the scan does start but doesn't find the beacon.id I'm searching. The real problem that is making me crazy and not knowing where to turn, is that on Android 11 both apps find the beacon I'm searching. I know about the permission differences between Android ≤ 11 and Android ≥ 12, and I think this is not the problem because the scan shouldn't start at all if it was.
I've tried different scanMode(s), allowDuplicates: true/false and legacyScan: true/false. No success.
I've tried these apps on Android 11, Android 14 and iOS 17.5.1. The beacon I'm using: amazon.it link