handle stuck state with granular android permissions

zio/stable
Eric Bailey 2023-08-29 17:09:38 -05:00
parent 6bee7d518b
commit 5710140a73
1 changed files with 8 additions and 3 deletions

View File

@ -29,9 +29,14 @@ export function usePhotoLibraryPermission() {
if (res?.granted) {
return true
} else if (!res || res?.status === 'undetermined' || res?.canAskAgain) {
const updatedRes = await requestPermission()
return updatedRes?.granted
} else if (!res || res.status === 'undetermined' || res?.canAskAgain) {
const {canAskAgain, granted, status} = await requestPermission()
if (!canAskAgain && status === 'undetermined') {
openPermissionAlert('photo library')
}
return granted
} else {
openPermissionAlert('photo library')
return false