Open shrouxm opened 3 months ago
const [status, requestPermission, asyncStatus] = ImagePicker.useCameraPermissions();
if you check the first status, its not updated but the asyncStatus is and after you start using the async status, the sync status is finally updated, not sure why, but if you dont request the async, the sync one is always stale.
Anyways, requesting the ImagePicker.getMediaLibraryPermissionsAsync as a fallback for the sync status worked for me, the same applies for the ImagePicker.getCameraPermissionsAsync
Might be dependent on an upstream fix, let's see if we can find a workaround. If there is an outside dependency, leave a note.
Here's where we're at after PR #2167 – if you run into a bug like this:
App Version
1.0.0 (160)
Account
No response
Platforms
Description
The expo permissions hooks do not seem to update when permissions are modified via either platform's settings page or the app. See steps to reproduce for a more detailed account. I have filed a bug with expo so hopefully it can get fixed upstream, and tried some workarounds to fix but none that didn't create other weird behaviors so I'm giving up for now.
Steps to Reproduce
Expected behavior
The button should do what it's supposed to do since the user has now granted permission.
Actual behavior
The button displays the "go to settings" modal again.
Additional context
This affects:
I tried to workaround by requesting permissions at the time the user presses the button rather than via the hook, but couldn't get that to work in a way that fits the different behaviors of all the screens this affects.
Some other possible workarounds:
AppState
API to resolve the bug downstreamNotes
useForegroundPermissions()
) are correct only immediately after one of the async functions it returns (getPermissions
orrequestPermissions
) are called. Otherwise, the hook may return an outdated permission status. And updating app permissions will not trigger a re-render because the hook is not listening for changes to app permissions.