I'm siging in users with the Email/Password method on Firebase. I'm not interested in switching to phone authentication. That being said, I'd like to store the users phone number in their profile for later access.
I know I can store it like so:
Users/UID/PhoneNumber: XXXXXX
But I'd like to be able to access it at a later date without having to query for that user id. Rather I'd like to store it so I can get at it through currentUser.phoneNumber or something similar.
I know there updateProfile which takes a displayName and profilePic but the documentation doesn't seem to allow phoneNumber. Is there anyway to achieve this?
You can't get the user phone doing something like this:
mAuth = FirebaseAuth.getCurrentUser().getPhoneNumber();
as you cannot access directly the user phone without implementing Firebase Phone Auth.
Since you don't care if that number is from that person, a workaround would be doing an AlertDialog
or an EditText
to prompt the user to type the desired number you want to store, and yes, you will need to query it each time since you are not getting it from Auth
.
The only way possible of getting the user phone number in the userInfo as you say without querying the database is implementing Phone Auth.
Doing the workaround there is no guarantee that the phone number entered by the user is the right one