Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding createUser function of firebase(specifically android library)

So I have the following code that I got from the firebase documentation (which I implemented in my app already and it's working fine):

    Firebase ref = new Firebase("https://myapp.firebaseio.com");
    ref.createUser("[email protected]", "correcthorsebatterystaple", new Firebase.ValueResultHandler<Map<String, Object>>() {
       @Override
       public void onSuccess(Map<String, Object> result) {
          System.out.println("Successfully created user account with uid: " + result.get("uid"));
       }
       @Override
       public void onError(FirebaseError firebaseError) {
        // there was an error
       }
    });

after I create a user it prints on the console its uid. However, when I enter in my myapp.firebaseio.com there is nothing there.. So I have some questions:

  1. Where does firebase stores this new user created?
  2. How can I add some custom fields? (this functions uses just email and password) i.e Username

So, What I have tried to do was inside the onSuccess() I used ref.push() some values to myapp.firebaseio.com but then .. how can I check if the users uid created by the createUser() is the same as the one who I pushed? (the id's are differente!)

I hope my text it's clear, if isn't asked and I can try to explain again!

Thanks a bunch!

like image 369
Bruno da Cruz Avatar asked Sep 09 '15 22:09

Bruno da Cruz


People also ask

What is Firebase and how it works in Android?

Firebase is a mobile platform that helps you quickly develop high-quality apps, grow your user base, and earn more money. Firebase is made up of complementary features that you can mix-and-match to fit your needs, with Google Analytics for Firebase at the core.

How can I tell if someone has logged into my Android?

According to this: To check if the user is signed-in, call isConnected(). if (mGoogleApiClient != null && mGoogleApiClient.

What does Firebase auth () CurrentUser return?

What does Firebase auth () CurrentUser return? If a user isn't signed in, CurrentUser returns null. Note: CurrentUser might also return null because the auth object has not finished initializing.


1 Answers

User information is not stored inside your Firebase database. For anonymous and OAuth users, no information is stored anywhere. The information for email+password users is kept in a separate database that you don't have access to. The email+password users are visible in the Login & Auth tab of your dashboard of course, just not in your database.

If you want to store user information in your own Firebase database, you have to store it there yourself when you create or authenticate the user. There is a section on storing user data in the Firebase documentation that shows how to do this.

One advantage of having to store the information yourself, is that you get to determine exactly what is and what isn't stored.

like image 68
Frank van Puffelen Avatar answered Oct 02 '22 20:10

Frank van Puffelen