Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [IOAPPX-479] Fix camera permission request on Android devices #6687

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mastro993
Copy link
Contributor

@mastro993 mastro993 commented Feb 4, 2025

Short description

This PR refactors the camera permission request logic on Android to align with the platform-specific behavior.

Detailed description

On Android, camera permission handling logic differs from iOS. When the app checks the permission status for the first time it receives a "denied" response, but this does not necessarily mean that the user has explicitly denied access and it simply can indicate that the permission has not been requested yet.
To address this, we decided to show the permission prompt as soon the user navigates to the barcode scanner screen.

This change only addresses Android, the logic remains unchanged on iOS.

Demo

Registrazione.schermo.2025-02-05.alle.14.38.30.mov

List of changes proposed in this pull request

  • Added useCameraPermissionStatus hook to separate camera permission request logic from useIOBarcodeCameraScanner
  • On Android, if the camera permission is "denied", the app requires camera access as soon the user navigates to the barcode scanner screen
  • Added a LoadingSpinner to BarcodeScanBaseScreenComponent when the camera permission is undefined

How to test

With an Android device: navigate to the barcode scanner screen and verify the following behaviors:

  • On the first visit, the screen should display the system camera permission prompt
  • After clicking "Deny", the screen should display the "Access denied" component with a "Go to Settings" button
  • After enabling camera access in the device settings and returning to the app, the camera view should be displayed correctly

With an iOS device: navigate to the barcode scanner screen and verify that there aren't regressions.

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Jira Pull Request Link

This Pull Request refers to Jira issues:

Copy link
Contributor

github-actions bot commented Feb 4, 2025

PR Title Validation for conventional commit type

All good! PR title follows the conventional commit type.

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 31.25000% with 22 lines in your changes missing coverage. Please review.

Project coverage is 49.93%. Comparing base (94eab6a) to head (a71e104).

Files with missing lines Patch % Lines
...eatures/barcode/hooks/useCameraPermissionStatus.ts 4.54% 21 Missing ⚠️
...code/components/BarcodeScanBaseScreenComponent.tsx 90.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6687      +/-   ##
==========================================
- Coverage   49.95%   49.93%   -0.02%     
==========================================
  Files        1540     1541       +1     
  Lines       32192    32204      +12     
  Branches     7295     7300       +5     
==========================================
+ Hits        16081    16082       +1     
- Misses      16072    16084      +12     
+ Partials       39       38       -1     
Files with missing lines Coverage Δ
...atures/barcode/hooks/useIOBarcodeCameraScanner.tsx 18.33% <ø> (+2.84%) ⬆️
...code/components/BarcodeScanBaseScreenComponent.tsx 77.14% <90.00%> (-1.12%) ⬇️
...eatures/barcode/hooks/useCameraPermissionStatus.ts 4.54% <4.54%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94eab6a...a71e104. Read the comment docs.

@mastro993 mastro993 marked this pull request as draft February 5, 2025 08:06
@mastro993 mastro993 force-pushed the IOAPPX-479-fix-camera-permissions-request-on-android-devices branch from 531604a to df26774 Compare February 5, 2025 13:16
@mastro993 mastro993 self-assigned this Feb 5, 2025
@mastro993 mastro993 added the Cross label Feb 5, 2025
@mastro993 mastro993 marked this pull request as ready for review February 5, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant