How can I register a username in Firebase?

前端 未结 3 1239
醉话见心
醉话见心 2021-01-24 21:07

I am trying to implement the registration of a username in Firebase since it only gives me methods that are like the createUserWithEmailAndPassword(), but you can n

3条回答
  •  心在旅途
    2021-01-24 21:37

    You cannot store custom data within a firebase user per se, according to firebase documentation

    You cannot add other properties to the Firebase User object directly; instead, you can store the additional properties in your Firebase Realtime Database.

    Since each registered user has a unique id that you can access with

    FirebaseAuth.getInstance().getCurrentUser().getUid()
    

    once the user logs in, you can create a table in the realtime database that stores data of each user using your User class. Then you can query the database for the logged in user using the snippet above for the Uid.

    More info here: https://firebase.google.com/docs/auth/users

提交回复
热议问题