-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add verifyPhoneNumber #38
Comments
Hi @kyleabens, import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signInWithPhoneNumber = async () => {
const { verificationId } = await FirebaseAuthentication.signInWithPhoneNumber(
{
phoneNumber: '123456789',
},
);
const verificationCode = window.prompt(
'Please enter the verification code that was sent to your mobile device.',
);
await FirebaseAuthentication.signInWithPhoneNumber({
verificationId,
verificationCode,
});
}; Let me know if this is what you are looking for. |
@robingenz verifyPhoneNumber for multi factor authentication is a little different since it takes a session instead of a phone number. Would love to see this added as an option. Should still return a verification ID. I’ve been trying to piece it together by modifying the plugin but I’m struggling with swift and type casting. I keep getting an error when I try to use cap.getObject(“session”) because it’s then not the right type when passing to verifyPhoneNumber as MultiFactorSession type. I’m new to a lot of this so any advice would be great. This is the exact error I get in xcode when I try to pass the session that I obtain in my ionic app
|
Okay, i will have a look 👍 |
Just as a side note, this would probably come in handy using the Multi-factor Auth: |
any update on adding this? |
Hi, did you find a solution @kyleabens ? I also really need this. |
Also interested in this feature. I'm going to try creating a custom capacitor plugin just for the MFA feature on iOS but I would really love to just use this plugin instead. Any updates? |
Looking to do the same, any updates? |
I did a quick and dirty patch to enable MFA on iOS: 2fe9ba0 This is really ugly, it was just the minimum and the fastest way to get something working.
Not ideal at all but at least I was able to send the SMS to enroll second factors and on sign in when MFA is enabled. |
I've noticed the problem with this it will only sign the user in on the native layer with MFA, however if we want to also sign them in on the JS layer (essential to use Firestore), it's not possible? So for example, we sign the user in using your patch (on the native layer), we then take the credential returned and use this on the JS layer with signInWithCredential(auth, credential), would this 2nd call to login on the JS layer now fail with the error "auth/multi-factor-auth-required"? |
I login the user both on the native layer and the JS layer in parallel and I use the verificationId from the native layer in the JS layer (and luckily it works). This is what I do in JS:
|
How will this work when we need to enroll users in MFA? There's a different process that happens there (still relies on Recaptcha) |
That's why I added the In JS:
This way the SMS is sent on the native layer without using the racpatcha. |
Is this still the best approach for supporting phone number MFA on iOS @robingenz? |
"best" can't be used here, let's say the "less bad" lol. This is really not a good and reliable solution, besides I have a lot of problems with reCaptcha verification on iOS when silent notifications don't work (https://firebase.google.com/docs/auth/ios/phone-auth#set-up-recaptcha-verification), I don't understand how to deal with it. |
Well, I finally added
in
of Again, a quick and dirty way to make things work. |
With same package and feature I'm getting this error, Module not found: Error: Can't resolve 'firebase/auth' in '/ionic-app/node_modules/@capacitor-firebase/authentication/dist/esm |
Hey @kyleabens @robingenz However when we try to send OTP It's opening chrome and verifying recaptcha automatically.. How can I avoid that? `
` |
Any update on above ? Google has changed their ways of verifying request using App Check. But We don't have option to verify app-check with this sdk... I think that's the reason |
No updates yet. I'm currently working on a few other issues. Feel free to submit a PR. I will take a look then. |
Is your feature request related to a problem? Please describe:
I use two-factor authentication in my app and would love it if you could implement verifyPhoneNumber. I'm not sure if signInWithPhoneNumber would work in this case (I haven't tried it yet);
Describe the solution you'd like:
To be able to generate a verificationId with verifyPhoneNumber.
Describe alternatives you've considered:
I've tried using the firebase sdk and it works on web and Android but iOS won't load the recaptcha needed to verify the phone number and generate the verificationId.
The text was updated successfully, but these errors were encountered: