Hi All!
Android 12 requires that you now explicitly request Bluetooth permissions rather than just requesting location. I can’t figure out how to request bluetooth permissions on android. More info below:
I’m using react-native-ble-plx and the new Expo plugin that allows you to use bluetooth without ejecting. On IOS it works perfectly and asks for bluetooth (nearby devices) access. On android it does not. Here is my app.json:
"plugins": ["expo-camera",["@config-plugins/react-native-ble-plx", {
"isBackgroundEnabled": true
}]],
"android": {
"package": "com.youareaccountable",
"permissions": ["CAMERA", "android.permission.BLUETOOTH_ADMIN", "android.permission.BLUETOOTH_CONNECT", "ACCESS_COARSE_LOCATION", "android.permission.BLUETOOTH_ADVERTISE", "BLUETOOTH_SCAN", "BLUETOOTH", "ACCESS_FINE_LOCATION"],
"versionCode": 11
},
I also tried requesting the permissions as just “BLUETOOTH_SCAN” etc.
Thank you for any insight you have!
wodin
May 17, 2022, 6:48pm
2
Yes, but that doesn’t work in the managed workflow as far as I could tell. Trying to get this working within the managed workflow.
wodin
May 17, 2022, 6:56pm
4
From the installation instructions it looks like it should work out of the box on Android as long as you build with EAS Build, which you’ll also need to do for the Bluetooth support.
When I had tried it, my iphone app would no longer load on the developer build and would crash on the internal build.
Okay figured it out! I needed to do the following:
Upgrade from SDK 44 to 45 because RN .66 and higher have the new Android Permissions
Import PermissionsAdnroid from “react-native”
Request Permissions:
if (Platform.OS === "android") {
// console.log(PermissionsAndroid.PERMISSIONS);
status = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN);
// console.log(status);
status = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT);
// console.log(status);
}
app.json:
"plugins": ["expo-camera",["@config-plugins/react-native-ble-plx", {
"isBackgroundEnabled": true
}]],
"android": {
"package": "com.youareaccountable",
"permissions": ["CAMERA", "BLUETOOTH_ADMIN", "BLUETOOTH_CONNECT", "ACCESS_COARSE_LOCATION", "BLUETOOTH_ADVERTISE", "BLUETOOTH_SCAN", "BLUETOOTH", "ACCESS_FINE_LOCATION"],
"versionCode": 11
},
Hopefully this saves someone a lot of time
1 Like
system
Closed
June 6, 2022, 8:20pm
7
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.