Working on secure device lock authentication with automatic app locking.
This commit is contained in:
34
src/screen/Managelock.tsx
Normal file
34
src/screen/Managelock.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { AppState, View, Text } from 'react-native';
|
||||
|
||||
const App = () => {
|
||||
const [locked, setLocked] = useState(true);
|
||||
const [pinExists, setPinExists] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
isPinSet().then(setPinExists);
|
||||
isAppLocked().then(setLocked);
|
||||
|
||||
const sub = AppState.addEventListener('change', state => {
|
||||
if (state !== 'active') lockApp();
|
||||
});
|
||||
|
||||
return () => sub.remove();
|
||||
}, []);
|
||||
|
||||
if (!pinExists) {
|
||||
return <SetPinScreen onDone={() => setPinExists(true)} />;
|
||||
}
|
||||
|
||||
if (locked) {
|
||||
return <LockScreen onUnlock={() => setLocked(false)} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
||||
<Text>🔓 App Unlocked (Home Screen)</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
Reference in New Issue
Block a user