Firebase Detecting if user exists

后端 未结 4 1002
天涯浪人
天涯浪人 2021-01-11 12:16

How Can I Check user exists in Firebase auth in Signup Button via react native?

This is my Login Page Code:

export de         


        
4条回答
  •  执念已碎
    2021-01-11 12:35

    Here's how to use the fetchSignInMethodsForEmail API. It returns an array. If the array is empty, it means the user has never signed up/signed in to your app with the sign in methods you have used in your app.

    This is an example with Google signin.

    firebase
        .auth()
        .signInWithPopup(provider)
        .then((result) => {
            let token = result.credential.accessToken;
            let user = result.user;
    
            firebase
                .auth()
                .fetchSignInMethodsForEmail(user.email)
                .then((result) => {
                    console.log('result', result);
                });
            })
            .catch((error) => {
                // Handle Errors here.
            }
    

提交回复
热议问题