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/ios wrong permission message #30374

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3105687
fix: wrong alert message for microphone permission error
ishpaul777 Oct 25, 2023
ea5b6c9
added requested changes
ishpaul777 Oct 26, 2023
c4bdd27
fix conflicts
ishpaul777 Oct 30, 2023
177d8b9
Merge branch 'main' into fix/ios-wrong-permission-message
ishpaul777 Oct 30, 2023
a7dd5e3
fix conflicts
ishpaul777 Oct 30, 2023
3d18adf
fix imports
ishpaul777 Oct 30, 2023
967569d
fix lint
ishpaul777 Oct 31, 2023
729f264
fix prettier difffs
ishpaul777 Oct 31, 2023
efe6754
made change specific to ios
ishpaul777 Nov 1, 2023
9482050
Merge branch 'Expensify:main' into fix/ios-wrong-permission-message
ishpaul777 Nov 3, 2023
f46a771
fix no modal error on mic permission
ishpaul777 Nov 3, 2023
b1c9a56
changes copy for alert message in english
ishpaul777 Nov 9, 2023
5f44d6b
fix lint
ishpaul777 Nov 9, 2023
005fd9f
Merge branch 'Expensify:main' into fix/ios-wrong-permission-message
ishpaul777 Nov 13, 2023
3262454
copy updated
ishpaul777 Nov 15, 2023
43be729
Merge branch 'fix/ios-wrong-permission-message' of https://github.com…
ishpaul777 Nov 15, 2023
5991701
fix lint
ishpaul777 Nov 15, 2023
0584882
fix title for error message
ishpaul777 Nov 21, 2023
8ba7176
Merge branch 'Expensify:main' into fix/ios-wrong-permission-message
ishpaul777 Nov 21, 2023
7ca308e
Merge branch 'Expensify:main' into fix/ios-wrong-permission-message
ishpaul777 Dec 8, 2023
8c73e7d
Update src/components/Onfido/index.native.js
ishpaul777 Dec 11, 2023
924247d
Update src/components/Onfido/index.native.js
ishpaul777 Dec 11, 2023
585e322
Merge branch 'Expensify:main' into fix/ios-wrong-permission-message
ishpaul777 Dec 11, 2023
099c7fa
Update CONST.ts
ishpaul777 Dec 11, 2023
b85636f
Update src/languages/en.ts
ishpaul777 Dec 11, 2023
8c0b10b
Update src/languages/en.ts
ishpaul777 Dec 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 48 additions & 24 deletions src/components/Onfido/index.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import _ from 'underscore';
import lodashGet from 'lodash/get';
import React, {useEffect} from 'react';
import {Alert, Linking} from 'react-native';
import {Alert, Linking, Platform} from 'react-native';
import {RESULTS, PERMISSIONS, checkMultiple} from 'react-native-permissions';
import {Onfido as OnfidoSDK, OnfidoCaptureType, OnfidoDocumentType, OnfidoCountryCode} from '@onfido/react-native-sdk';
import onfidoPropTypes from './onfidoPropTypes';
import CONST from '../../CONST';
Expand Down Expand Up @@ -39,30 +40,53 @@ function Onfido({sdkToken, onUserExit, onSuccess, onError}) {
return;
}

// Handle user camera permission on iOS and Android
if (_.contains([CONST.ONFIDO.ERROR.USER_CAMERA_PERMISSION, CONST.ONFIDO.ERROR.USER_CAMERA_DENINED, CONST.ONFIDO.ERROR.USER_CAMERA_CONSENT_DENIED], errorMessage)) {
Alert.alert(
translate('onfidoStep.cameraPermissionsNotGranted'),
translate('onfidoStep.cameraRequestMessage'),
[
{
text: translate('common.cancel'),
onPress: () => onUserExit(),
},
{
text: translate('common.settings'),
onPress: () => {
onUserExit();
Linking.openSettings();
},
},
],
{cancelable: false},
);
return;
}
if (!_.isEmpty(errorMessage)) {
const micPermission = Platform.select({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform.select is not preferred. Please re-use iou/ReceiptSelector/CameraPermission structure to handle platform specific permissions.

android: PERMISSIONS.ANDROID.RECORD_AUDIO,
ios: PERMISSIONS.IOS.MICROPHONE,
});
const cameraPermission = Platform.select({
android: PERMISSIONS.ANDROID.CAMERA,
ios: PERMISSIONS.IOS.CAMERA,
});
checkMultiple([micPermission, cameraPermission]).then((statuses) => {
const isMicAllowed = statuses[micPermission] === RESULTS.GRANTED;
const isCameraAllowed = statuses[cameraPermission] === RESULTS.GRANTED;
let alertTitle = '';
let alertMessage = '';
if (!isMicAllowed) {
alertTitle = 'onfidoStep.microphonePermissionsNotGranted';
alertMessage = 'onfidoStep.microphoneRequestMessage';
}
if (!isCameraAllowed) {
alertTitle = 'onfidoStep.cameraPermissionsNotGranted';
alertMessage = 'onfidoStep.cameraRequestMessage';
}

onError(errorMessage);
if (!_.isEmpty(alertTitle) && !_.isEmpty(alertMessage)) {
Alert.alert(
translate(alertTitle),
translate(alertMessage),
[
{
text: translate('common.cancel'),
onPress: () => onUserExit(),
},
{
text: translate('common.settings'),
onPress: () => {
onUserExit();
Linking.openSettings();
},
},
],
{cancelable: false},
);
return;
}
onError(errorMessage);
});
}
});
// Onfido should be initialized only once on mount
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,8 @@ export default {
genericError: 'There was an error while processing this step. Please try again.',
cameraPermissionsNotGranted: 'Camera permissions not granted',
cameraRequestMessage: 'You have not granted us camera access. We need access to complete verification.',
microphonePermissionsNotGranted: 'Microphone permissions not granted',
microphoneRequestMessage: 'You have not granted us microphone access. We need access to complete verification.',
originalDocumentNeeded: 'Please upload an original image of your ID rather than a screenshot or scanned image.',
documentNeedsBetterQuality: 'Your ID appears to be damaged or has missing security features. Please upload an original image of an undamaged ID that is entirely visible.',
imageNeedsBetterQuality: "There's an issue with the image quality of your ID. Please upload a new image where your entire ID can be seen clearly.",
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,8 @@ export default {
genericError: 'Hubo un error al procesar este paso. Inténtalo de nuevo.',
cameraPermissionsNotGranted: 'No has habilitado los permisos para acceder a la cámara',
cameraRequestMessage: 'No has habilitado los permisos para acceder a la cámara. Necesitamos acceso para completar la verificaciôn.',
microphonePermissionsNotGranted: 'No has habilitado los permisos para acceder al micrófono',
microphoneRequestMessage: 'No has habilitado los permisos para acceder al micrófono. Necesitamos acceso para completar la verificaciôn.',
originalDocumentNeeded: 'Por favor, sube una imagen original de tu identificación en lugar de una captura de pantalla o imagen escaneada.',
documentNeedsBetterQuality:
'Parece que tu identificación esta dañado o le faltan características de seguridad. Por favor, sube una imagen de tu documento sin daños y que se vea completamente.',
Expand Down
Loading