I have been authenticating user from facebook on firebase but i want to make them set their phone numbers linked to the user but i cant find any way to make them set their phone number i can only retrieve using FirebaseUser user.getPhoneNumber and update phonenumber needs credentials not string which i don't know how to use so can anyone help me ?!
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
user.getPhoneNumber();
user.updatePhoneNumber();
Firebase Auth verifies its own phone numbers. It doesn't populate Facebook phone numbers after a Facebook sign-in or something of the like.
However, if you have the phone number, you need to go through the verification process: verifyPhoneNumber
with the phone number to get the verificationId and then ask the user for the SMS code, populate a phone auth credential using the verification ID/code and then call user.updatePhoneNumber(phoneCredential)
.
Alternatively, if you already verified the phone number via some other means, you can send the user ID token and the phone number to your server. Using the Firebase Admin Node.js SDK, verify the ID token and then call updateUser
API with the phone number: https://firebase.google.com/docs/auth/admin/manage-users#update_a_user
You then user.reload()
the user on the client to update with the phone number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With