diff --git a/machines/biometrics.ts b/machines/biometrics.ts index b23a7b7a..71772767 100644 --- a/machines/biometrics.ts +++ b/machines/biometrics.ts @@ -1,6 +1,7 @@ import { createModel } from 'xstate/lib/model'; import * as LocalAuthentication from 'expo-local-authentication'; import { EventFrom, MetaObject, StateFrom } from 'xstate'; +import { Platform } from 'react-native'; // ----- CREATE MODEL --------------------------------------------------------- const model = createModel( @@ -97,6 +98,9 @@ export const biometricsMachine = model.createMachine( authenticating: { invoke: { src: () => async () => { + if (Platform.OS === 'android') { + await LocalAuthentication.cancelAuthenticate(); + } const res = await LocalAuthentication.authenticateAsync({ promptMessage: 'Biometric Authentication', @@ -112,6 +116,9 @@ export const biometricsMachine = model.createMachine( actions: ['setStatus'], }, }, + on: { + AUTHENTICATE: 'authenticating', + }, }, reauthenticating: { @@ -145,6 +152,7 @@ export const biometricsMachine = model.createMachine( SET_IS_AVAILABLE: { target: '#biometrics.available', }, + AUTHENTICATE: 'authenticating', }, }, @@ -186,6 +194,9 @@ export const biometricsMachine = model.createMachine( }, }, }, + on: { + AUTHENTICATE: 'authenticating', + }, }, }, },