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 all commits
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
5 changes: 0 additions & 5 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1090,11 +1090,6 @@ const CONST = {
USER_CANCELLED: 'User canceled flow.',
USER_TAPPED_BACK: 'User exited by clicking the back button.',
USER_EXITED: 'User exited by manual action.',
USER_CAMERA_DENINED: 'Onfido.OnfidoFlowError',
USER_CAMERA_PERMISSION: 'Encountered an error: cameraPermission',
// eslint-disable-next-line max-len
USER_CAMERA_CONSENT_DENIED:
'Unexpected result Intent. It might be a result of incorrect integration, make sure you only pass Onfido intent to handleActivityResult. It might be due to unpredictable crash or error. Please report the problem to [email protected]. Intent: null \n resultCode: 0',
},
},

Expand Down
68 changes: 45 additions & 23 deletions src/components/Onfido/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import {OnfidoCaptureType, OnfidoCountryCode, OnfidoDocumentType, Onfido as Onfi
import lodashGet from 'lodash/get';
import React, {useEffect} from 'react';
import {Alert, Linking} from 'react-native';
import {checkMultiple, PERMISSIONS, RESULTS} from 'react-native-permissions';
import _ from 'underscore';
import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import useLocalize from '@hooks/useLocalize';
import getPlatform from '@libs/getPlatform';
import Log from '@libs/Log';
import CONST from '@src/CONST';
import onfidoPropTypes from './onfidoPropTypes';
Expand Down Expand Up @@ -39,30 +41,50 @@ 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) && getPlatform() === CONST.PLATFORM.IOS) {
checkMultiple([PERMISSIONS.IOS.MICROPHONE, PERMISSIONS.IOS.CAMERA])
.then((statuses) => {
const isMicAllowed = statuses[PERMISSIONS.IOS.MICROPHONE] === RESULTS.GRANTED;
const isCameraAllowed = statuses[PERMISSIONS.IOS.CAMERA] === RESULTS.GRANTED;
let alertTitle = '';
let alertMessage = '';
if (!isCameraAllowed) {
alertTitle = 'onfidoStep.cameraPermissionsNotGranted';
alertMessage = 'onfidoStep.cameraRequestMessage';
} else if (!isMicAllowed) {
alertTitle = 'onfidoStep.microphonePermissionsNotGranted';
alertMessage = 'onfidoStep.microphoneRequestMessage';
}

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);
})
.catch(() => {
onError(errorMessage);
});
} else {
onError(errorMessage);
}
});
// Onfido should be initialized only once on mount
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
6 changes: 4 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,10 @@ export default {
tryAgain: 'Try again',
verifyIdentity: 'Verify identity',
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.',
cameraPermissionsNotGranted: 'Enable camera access',
cameraRequestMessage: 'We need access to your camera to complete bank account verification. Please enable via Settings > New Expensify.',
microphonePermissionsNotGranted: 'Enable microphone access',
microphoneRequestMessage: 'We need access to your microphone to complete bank account verification. Please enable via Settings > New Expensify.',
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
7 changes: 5 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1279,8 +1279,11 @@ export default {
tryAgain: 'Intentar otra vez',
verifyIdentity: 'Verificar identidad',
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.',
cameraPermissionsNotGranted: 'Permiso para acceder a la cámara',
cameraRequestMessage: 'Necesitamos acceso a tu cámara para completar la verificación de tu cuenta de banco. Por favor habilita los permisos en Configuración > Nuevo Expensify.',
microphonePermissionsNotGranted: 'Permiso para acceder al micrófono',
microphoneRequestMessage:
'Necesitamos acceso a tu micrófono para completar la verificación de tu cuenta de banco. Por favor habilita los permisos en Configuración > Nuevo Expensify.',
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