简体   繁体   中英

How to determine if the user has signed up using email in Firebase?

I already did a Google Sign check. But I don't know how to realize email check.

for (UserInfo user: FirebaseAuth.getInstance().getCurrentUser().getProviderData()) {
            if (user.getProviderId().equals("google.com")) {
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                SplashActivity.this.startActivity(intent);
            }else if (user.getEmail().equals("email")) {

                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                SplashActivity.this.startActivity(intent);
            }
        }

If you have multiple authentication mechanisms, then you should use FirebaseAuth's fetchSignInMethodsForEmail() method:

Returns a list of signin methods that can be used to sign in a given user (identified by its main email address). This will match the getSignInMethod() for the credential you would generate for the appropriate signin mechanism.

This method is useful when you support multiple authentication mechanisms if you want to implement an email-first authentication flow. It is also useful to resolve a FirebaseAuthUserCollisionException thrown on signInWithCredential(AuthCredential) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM