add basic fingerprint auth on app launch

This commit is contained in:
ammarahm-ed
2021-03-01 09:51:53 +05:00
parent c74cfaf93f
commit df65a504ae
3 changed files with 64 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import React, {useEffect} from 'react';
import {BackHandler} from 'react-native';
import Orientation from 'react-native-orientation';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import SplashScreen from 'react-native-splash-screen';
@@ -7,7 +8,9 @@ import {RootView} from './initializer.root';
import AppLoader from './src/components/AppLoader';
import {useTracked} from './src/provider';
import {Actions} from './src/provider/Actions';
import BiometricService from './src/services/BiometricService';
import {DDS} from './src/services/DeviceDetection';
import RNExitApp from 'react-native-exit-app';
import {
eSendEvent,
eSubscribeEvent,
@@ -36,10 +39,28 @@ const App = () => {
: 'mobile',
});
});
let func = async () => {
eSendEvent(eOpenSideMenu);
SplashScreen.hide();
await db.init();
};
await SettingsService.init();
eSendEvent(eOpenSideMenu);
SplashScreen.hide();
await db.init();
if (SettingsService.get().appLockMode !== 'none') {
let result = await BiometricService.validateUser(
'Unlock to access your notes',
'',
);
if (result) {
await func();
} else {
RNExitApp.exitApp();
return;
}
} else {
await func();
}
} catch (e) {
} finally {
initStatus = true;