I am debugging a react native app that absolutely needs bluetooth permissions, however at the moment in android the bluetooth permissions are returning unavailable
.
I am requesting permissions in my AndroidManifest.xml like this:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
And I am checking the status of bluetooth permissions like this:
const checkBluetoothPermissions = () => {
requestMultiple(
Platform.OS === 'android'
? [
PERMISSIONS.ANDROID.BLUETOOTH_SCAN,
PERMISSIONS.ANDROID.BLUETOOTH_CONNECT,
PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
]
: [PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL],
).then(_ => {
console.log('permission results', _);
});
};
What is being logged from this function is
permission results {"android.permission.ACCESS_FINE_LOCATION": "granted", "android.permission.BLUETOOTH_CONNECT": "unavailable", "android.permission.BLUETOOTH_SCAN": "unavailable"}
And when installing the app the only permission that is asked is location
and I do not know why.
I followed the instructions here: react-native-permissions.
There is no issue on IOS from the same codebase.
2
Answers
do it like this
and call this function
It should implicitly include BLUETOOTH_SCAN and BLUETOOTH_CONNECT by requesting the BLUETOOTH permission. Because location permission is frequently needed for Bluetooth functionality, make sure it’s also being requested.