-
Notifications
You must be signed in to change notification settings - Fork 49
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
Not Working in Android Version 12 and Above #121
Comments
You need to ask for BLUETOOTH_SCAN and BLUETOOTH_CONNECT permissions too for that newer versions. |
@KaiValar even with BLUETOOTH_SCAN and BLUETOOTH_CONNECT it is not working in Android 14. There is any other advice? |
Have you a repo to check it out? I have an app running it with this lib on Android 14, but I cannot share the code beacuse isn't really mine, I'm only an employee ^^' You need to add permissions and the service from Kontakt SDK on Manifest, add the SDK on your build.gradle dependencies (I used 7.1.8 version) and initialize it on MainApplication.java, then you can ask for the permissions to user and finally use the lib. On iOS is more painful, but atm on Android works fine. |
@KaiValar thanks for the fast reply. Our Manifest:
and this:
this in the build.gradle:
And this is the listener that doesn't work on Android 14 (but works on Android 12).
The initialize onCreate in MainApplication.java is not needed for us because we don't use the API Key (or at least, it doesn't work without an API key). Also we followed everything in this guide: https://github.com/Driversnote-Dev/react-native-kontaktio/tree/master Any recommendation is appreciated. Thanks in advance! |
Weird, at least I remember you have more or less the same than us. The unique differences I see are: we initialize the SDK in the onCreate just keeping a empty string ("") as a param and our function handler for the event insn't asyncronous, we call async functions inside the handler:
Maybe with the code front of me I can give you some extra info. Tomorrow, I'll try to got some time to see our code for got sure. |
@KaiValar After many many attempts, we found the solution on a comment of another bluetooth library with similar issue here, where Android 12 worked fine, on Android 14 didn't.
Basically this saved the day! The problem was that by adding this (mandatory for Android 12+, api 31+):
The merged Manifest resulted in this:
If android:usesPermissionFlags=neverForLocation is added in your android manifest, some BLE beacons are filtered out from the scan results. The Android documentation says:
Basically the automatically added "neverForLocation" was filtering out some BLE beacons... |
Glad to read you solve that :D Yeah, that change was added because if we detect a beacon, we can know you are on the same location of the beacon, so we can know where are you through the Bluetooth :P |
Btw, @jkaos92 if you are thinking to use this in background, I used a Foreground Service ;) |
@KaiValar Tomorrow will check if it works in BG. Will keep you updated regarding the FG Service, but thanks for the advice! |
it works fine in Android version 11 , for 12 and 13 Beacons did not register beacons are not shown in Range Anyone Please help me with this issue
I use latest Package
The text was updated successfully, but these errors were encountered: