Fix: Fail to request camera permission in Scan receipt screen#26231
Conversation
|
@mananjadhav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| const askForPermissions = () => { | ||
| if (permissions === 'not-determined') { | ||
| Camera.requestCameraPermission().then((permissionStatus) => { | ||
| // Android will never return blocked after a check, you have to request the permission to get the info. |
There was a problem hiding this comment.
Also mentioned in the doc: https://github.com/zoontek/react-native-permissions/blob/a836e114ce3a180b2b23916292c79841a267d828/README.md?plain=1#L670
There's no way we can check for the BLOCKED status without requesting the permission first, even with react-native's PermissionsAndroid.
Context: https://developer.android.com/training/permissions/requesting#workflow_for_requesting_permissions (point 4).
There was a problem hiding this comment.
I know this is a hack thus really looking forward to your feedback!
There was a problem hiding this comment.
I think we should put this in the description as comments. I think this is fine for the current change.
There was a problem hiding this comment.
You mean the PR description, right?
There was a problem hiding this comment.
- We should put a proper description on why we're doing along with the link in the code comment.
|
@tienifr Can you resolve the conflicts? |
mananjadhav
left a comment
There was a problem hiding this comment.
Code change looks fine, once conflicts are resolved, I'll test.
|
@mananjadhav Conflicts resolved! |
Reviewer Checklist
Screenshots/VideosWebweb-scan-receipt.movMobile Web - Chromemweb-chrome-scan-receipt.movMobile Web - Safarimweb-safari-scan-receipt.movDesktopdesktop-scan-receipt.moviOSios-scan-receipt.movAndroidandroid-scan-receipt.mov |
|
@AndrewGable All yours. |
|
@AndrewGable looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
Oops, checklist test must have been running. It was green when I merged. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/AndrewGable in version: 1.3.65-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.65-7 🚀
|
|
🚀 Deployed to staging by https://github.com/AndrewGable in version: 1.3.66-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.66-3 🚀
|
| // Android will never return blocked after a check, you have to request the permission to get the info. | ||
| if (permissions === RESULTS.BLOCKED || isAndroidBlockedPermissionRef.current) { | ||
| Linking.openSettings(); | ||
| } else if (permissions === RESULTS.DENIED) { |
There was a problem hiding this comment.
Coming from #27442. We improved the UX to avoid the permission button does nothing on first click
Details
The app shows error message when tapping on the capture button. User is required to go to Settings to manually allow camera permission via Give permission CTA.
Basically, Android "allows" user to deny a specific permission twice. Otherwise, they would need to manually grant permission in Settings. Meanwhile iOS only "allows" once.
Fixed Issues
$ #24160
PROPOSAL: #24160 (comment)
Tests
Precondition: The device has not granted camera permission to NewDot app before.
=== On Android
=== On iOS
Offline tests
NA
QA Steps
Precondition: The device has not granted camera permission to NewDot app before.
=== On Android
=== On iOS
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
iOS
Screen.Recording.2023-08-30.at.00.15.47.mov
Android
Screen.Recording.2023-08-30.at.01.45.24.mov