baumblatt / capacitor-firebase-auth

Capacitor Firebase Authentication Plugin
MIT License
261 stars 129 forks source link

ios sign in with phone number #158

Open moblizeit opened 3 years ago

moblizeit commented 3 years ago

i am failing to find an example for implementing the phone number authentication on ios.

i have put the code like

cfaSignInPhone('+1' + phoneNum).subscribe((user) => { console.log(user.phoneNumber) })

this does send me the SMS. but where do I handle the part of SMS input and finishing the auth. any code example?

nelson6e65 commented 3 years ago

Check this section in the README:

https://github.com/baumblatt/capacitor-firebase-auth#notification-for-phone-verification-step

Then you get the verificationId and user enters the verificationCode, you can sign-in in the web layer:

const { verificationId, verificationCode } = anyMethodUsedToGetTheVerificationCodeAndVerificationIdWhenUserSubmitTheForm();

const credential = firebase.auth.PhoneAuthProvider.credential(verificationId, verificationCode);

firebase.auth().signInWithCredential(credential);