Open thnhat51202574 opened 18 hours ago
Error looks like you need to add the BLUETOOTH_SCAN
permission to the application. Is there something else that is showing up in the logs that leads you to believe this is not a configuration issue?
Hi @kenjdavidson, thank you for responding.
These are the permissions we added to the AndroidManifest.xml
:
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" tools:targetApi="s" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
The issue never happens if the user accepts/allows the permission request. However, if the user opens the app for the first time (without taking any additional action) and then changes the device settings, we encounter a crash
That sounds about right, there is information on the React Native site (and maybe these docs) saying that you need to manage that, you shouldn't be attempting to access anything without requesting permission. You should be able to handle that by wrapping all the bluetooth logic in a wrapper that checks if they've already give permission.
https://kenjdavidson.com/react-native-bluetooth-classic/android/#android-permissions
If you feel like this needs more information, once you sort it out feel free to open a PR updating the docs for future users.
@kenjdavidson
We have handled the permission request in our app, but it doesn't seem to be relevant.
The issue occurs immediately after installing react-native-bluetooth-classic
without adding any additional code.
The onHostDestroy
function is registered in the Android codebase after running the yarn install
command
Mobile Device Environment Provide a list of operating systems on which this issue is relevant.
Application Environment Provide information about your development environment:
Describe the bug
To Reproduce
Prerequisite: Bluetooth on the device is turned on.
Steps:
The reason: function
onHostDestroy
is trigered and throw the exception.Screenshots
Additional context Add any other context about the problem here.