techmatters / terraso-mobile-client

A React Native project for Terraso’s LandPKS mobile application.
https://landpks.terraso.org
GNU Affero General Public License v3.0
2 stars 0 forks source link

bug: app permissions do not update immediately when changed in settings #1749

Open shrouxm opened 3 months ago

shrouxm commented 3 months ago

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

  1. Navigate to a screen that has a permissions interaction (e.g. home screen, soil color screen in the photo workflow).
  2. Deny the relevant permission, or turn it off in settings.
  3. Press the button that initiates the permissions interaction (e.g. location button on home screen map, "Use camera" button in photo workflow).
  4. Deny the permission again if the system prompt appears until the "go to settings" modal appears.
  5. Hit the "go to settings" button.
  6. Enable the relevant permission.
  7. Return to the app and hit the button that initiates the permissions interaction again.

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:

Notes

Silva404 commented 2 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

DerekCaelin commented 2 months ago

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.

knipec commented 4 weeks ago

Here's where we're at after PR #2167 – if you run into a bug like this: