Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppState and getGenericPassword #601

Open
ValyaBabenkov opened this issue Jun 21, 2023 · 1 comment
Open

AppState and getGenericPassword #601

ValyaBabenkov opened this issue Jun 21, 2023 · 1 comment

Comments

@ValyaBabenkov
Copy link

ValyaBabenkov commented Jun 21, 2023

Good afternoon.
Can you please tell me how to implement this approach, always request biometrics (getGenericPassword), when we change AppState to 'active'.

Right now I have a loop, as the FaceID screen - first makes the screen 'inactive', and when it activates successfully it makes it back to 'active' and then the loop goes on.

My code:

useEffect(() => {
        const listenerChangeAppState = async (state: string) => {
            if (state === 'active') {
                const credentials = await getGenericPassword();
....
            }
        };
        const appListener = AppState.addEventListener('change', listenerChangeAppState);
        return () => appListener.remove();
    }, []);
@Catdaemon
Copy link

Store the state in a ref when it is changed. Only update it when the state is different from the previous state, and only do this when the state is 'active' or 'background'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants