-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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: Fail to request camera permission in Scan receipt screen #26231
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] |
@@ -156,12 +159,14 @@ function ReceiptSelector(props) { | |||
}; | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is a hack thus really looking forward to your feedback!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the PR description, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
iOS
Screen.Recording.2023-08-30.at.00.15.47.mov
Android
Screen.Recording.2023-08-30.at.01.45.24.mov