diff --git a/src/CONST.ts b/src/CONST.ts index d4208d51a78c..e65ed6816e6f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1099,11 +1099,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 android-sdk@onfido.com. Intent: null \n resultCode: 0', }, }, diff --git a/src/components/Onfido/index.native.js b/src/components/Onfido/index.native.js index ed0578187d3c..b0a0b3f4a466 100644 --- a/src/components/Onfido/index.native.js +++ b/src/components/Onfido/index.native.js @@ -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'; @@ -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 diff --git a/src/languages/en.ts b/src/languages/en.ts index 40e666bb18c8..c4a481cb71c0 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1266,8 +1266,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.", diff --git a/src/languages/es.ts b/src/languages/es.ts index 86490f56ed2d..a91a8768a3ee 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1285,8 +1285,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.',