How to get the email of any user in Firebase based on user id?

前端 未结 5 1686
灰色年华
灰色年华 2020-12-09 04:48

I need to get a user object, specifically the user email, I will have the user id in this format:

simplelogin:6

So I need to write a function so

5条回答
  •  渐次进展
    2020-12-09 05:27

    simple get the firebaseauth instance. i created one default email and password in firebase. this is only for the security so that no one can get used other than who knows or who purchased our product to use our app. Next step we are providing singup screen for user account creation.

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
        String email = user.getEmail();
    

    every time user opens the app, user redirecting to dashboard if current user is not equal to our default email. below is the code

    mAuth = FirebaseAuth.getInstance();
        if (mAuth.getCurrentUser() != null){
            String EMAIL= mAuth.getCurrentUser().getEmail();
                if (!EMAIL.equals("example@gmail.com")){
                    startActivity(new Intent(LoginActivity.this,MainActivity.class));
                    finish();
                }
        }
    

    i Am also searching for the same solution finally i got it.

提交回复
热议问题