Skip to content

Commit

Permalink
Merge pull request #6969 from phivh/fix/blank-screen-when-user-denies…
Browse files Browse the repository at this point in the history
…-camera-access

fix: App shows blank screen when user denies camera access
  • Loading branch information
mountiny authored Jan 6, 2022
2 parents 51de5d9 + 2f5603d commit 5863d0f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ const CONST = {
ERROR: {
USER_CANCELLED: 'User canceled flow',
USER_TAPPED_BACK: 'User exited by clicking the back button.',
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
31 changes: 31 additions & 0 deletions src/components/Onfido/index.native.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'underscore';
import lodashGet from 'lodash/get';
import React from 'react';
import {Alert, Linking} from 'react-native';
import {
Onfido as OnfidoSDK,
OnfidoCaptureType,
Expand Down Expand Up @@ -45,6 +46,36 @@ class Onfido extends React.Component {
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(
this.props.translate('onfidoStep.cameraPermissionsNotGranted'),
this.props.translate('onfidoStep.cameraRequestMessage'),
[
{
text: this.props.translate('common.cancel'),
onPress: () => this.props.onUserExit(),
},
{
text: this.props.translate('common.settings'),
onPress: () => {
this.props.onUserExit();
Linking.openSettings();
},
},
],
{cancelable: false},
);
return;
}

this.props.onError(errorMessage);
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ export default {
selfSelect: 'Self-select',
callMeByMyName: 'Call me by my name',
},
cameraPermissionsNotGranted: 'Camera permissions not granted',
messages: {
errorMessageInvalidPhone: 'Please enter a valid phone number without brackets or dashes. If you\'re outside the US please include your country code, eg. +447782339811',
maxParticipantsReached: 'You\'ve reached the maximum number of participants for a group chat.',
Expand All @@ -523,6 +522,8 @@ 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.',
},
additionalDetailsStep: {
headerTitle: 'Additional details',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ export default {
selfSelect: 'Personalízalo',
callMeByMyName: 'Llámame por mi nombre',
},
cameraPermissionsNotGranted: 'No has habilitado los permisos para acceder a la cámara',
messages: {
errorMessageInvalidPhone: 'Por favor, introduce un número de teléfono válido sin paréntesis o guiones. Si reside fuera de Estados Unidos, por favor incluye el prefijo internacional. P. ej. +447782339811',
maxParticipantsReached: 'Has llegado al número máximo de participantes para un grupo.',
Expand All @@ -523,6 +522,8 @@ 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.',
},
additionalDetailsStep: {
headerTitle: 'Detalles adicionales',
Expand Down

0 comments on commit 5863d0f

Please sign in to comment.