Hi All!
So the first time the app runs on Android the app requests access to the:
- Location
- Camera
- Bluetooth
For some reason, the app crashes after requesting camera access and never gets to bluetooth. When running the app on an internal development build it doesn’t display any error. On subsequent runs it works fine. It only crashes on the first run of the app.
Code below:
//location/bluetooth
useEffect(() => {
(async () => {
if (Platform.OS === "android") {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== "granted") {
console.log(status);
setErrorMsg("Permission to access location was denied");
return;
}
let location = await Location.getCurrentPositionAsync({});
setLocation(location);
console.log(location);
status = await requestMultiple([
PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
PERMISSIONS.ANDROID.BLUETOOTH_SCAN,
PERMISSIONS.ANDROID.BLUETOOTH_CONNECT,
PERMISSIONS.ANDROID.BLUETOOTH_ADVERTISE,
]);
if (
status[PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION] === 'granted' &&
['granted', 'unavailable'].includes(
status[PERMISSIONS.ANDROID.BLUETOOTH_CONNECT],
) &&
['granted', 'unavailable'].includes(
status[PERMISSIONS.ANDROID.BLUETOOTH_SCAN],
) &&
['granted', 'unavailable'].includes(
status[PERMISSIONS.ANDROID.BLUETOOTH_ADVERTISE],
)
) {
}
}
})();
}, );
//camera permission
useEffect(() => {
(async () => {
console.log("camera granted");
const { status } = await Camera.requestCameraPermissionsAsync();
setHasPermission(status === "granted");
console.log("camera granted");
})();
}, [image]);
Thank you!