Reputation: 1
This question is a follow up to the answer here: Link Phone Number with Facebook and Gmail account in Firebase on Web
In the answer, the SMS code was collected using a prompt. But i would like to know how to collect it using a custom input field.
Thanks.
Upvotes: 0
Views: 289
Reputation: 30808
The use of prompt is just for illustration purposes and not the recommended flow.
result.user.linkWithPhoneNumber(phoneNumber, appVerifier)
.then(function(confirmationResult) {
// Show your UI where you ask user to input code.
document.getElementById('codeInputForm').style.display = 'block';
// Listen to code submit.
document.getElementById('codeInputSubmit')
.addEventListener('click', function() {
// Get code and verify it is not empty.
var code = document.getElementBydId('smsCode').value;
if (!code) {
return;
}
// Complete sign-in.
confirmationResult.confirm(code)
.then(function(result) {
// Successful linking.
gotoSuccessPage();
})
.catch(function(error) {
// Handler error;
});
})
})
Upvotes: 1