Hi, I’m having the same problem and was about to post a new topic when I found yours. I don’t have a solution, I’ll just add some info that may help find one.
- SDK 37
- Platforms Android/iOS/web: Android 9 and 10 on AVD emulator and BlueStacks and physical devices as well.
Other relevant info…
- Managed workflow
- The problem exists only on APK and doesn’t happen on Expo client (on iOS or Android). Haven’t done a TestFlight yet.
- I think the problem began when I updated SDK from 36 to 37. Same code was working before the update.
app.json permissions…
"permissions": [
"ACCESS_COARSE_LOCATION",
"ACCESS_FINE_LOCATION",
"CAMERA",
"READ_EXTERNAL_STORAGE",
"READ_INTERNAL_STORAGE",
"WRITE_EXTERNAL_STORAGE"
]
I’ve seen the problem described multiple times with earlier versions of SDK since 20 something. I think I tried most of the solutions proposed but I’m relatively new to Expo so the problem could very well be “between the keyboard and the chair”.
I’ll share the relevant part of the code that was working before the upgrade to 37.
useEffect(() => {
getPermissionAsync()
}, [])
const getPermissionAsync = async () => {
try {
const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL)
if (status !== "granted") {
alert("Se necesita permiso para la cámara...")
}
} catch (e) {
console.log(e)
}
}
and then I have a button that calls this next function onPress…
const _takePicture = async () => {
try {
let result = await ImagePicker.launchCameraAsync({
allowsEditing: false,
aspect: [4, 3],
quality: 0.8,
base64: true,
})
props.addPhoto(result)
} catch (e) {
console.log(e)
alert(e)
}
}
Since then I’ve added askAsync for Permissions.CAMERA as well in a few different ways (not sure which is preferred yet):
const statuses = await Promise.all([
Permissions.askAsync(Permissions.CAMERA_ROLL),
Permissions.askAsync(Permissions.CAMERA)
])
and also…
await Permissions.getAsync(Permissions.CAMERA_ROLL, Permissions.CAMERA)
and
await Permissions.askAsync(Permissions.CAMERA_ROLL)
await Permissions.askAsync(Permissions.CAMERA)
Still when ImagePicker.launchCameraAsync(…) gets called I catch the error:
Error: user rejected permissions.
I think the askAsync(Permission.CAMERA) never resolves…
Thank you for Expo and any help!