如何在 flutter web 中启用 firebase phone 验证?试了很多方法好像都不行,需要发短信验证码给用户
How to enable firebase phone verification in flutter web ? I have tried many ways but it doesn't seems to work, SMS code need to be sent to the user
我想通过使用 firebase 发送 OTP 来实现 phone 验证,该怎么做? .我已经尝试在 github 中关注此线程,但没有用它没有帮助,signInwithphoneNumber 仅登录用户而不通过发送 SMS OTP 代码验证用户,如何解决这个问题?
Github 线程 link:https://github.com/flutter/flutter/issues/46021
当我执行时抛出以下错误:
Error: UnimplementedError: verifyPhoneNumber() is not supported on the web. Please use
`signInWithPhoneNumber` instead.
有人可以帮我吗!!!
你必须使用
FirebaseAuth auth = FirebaseAuth.instance;
// Wait for the user to complete the reCAPTCHA & for an SMS code to be sent.
ConfirmationResult confirmationResult = await auth.signInWithPhoneNumber('+44 7123 123 456');
然后这个来验证
UserCredential userCredential = await confirmationResult.confirm('123456');
您还可以根据自己的使用添加RecaptchaVerifier,例如
ConfirmationResult confirmationResult = await auth.signInWithPhoneNumber('+44 7123 123 456', RecaptchaVerifier(
container: 'recaptcha',
size: RecaptchaVerifierSize.compact,
theme: RecaptchaVerifierTheme.dark,
));
您还可以编辑验证码
RecaptchaVerifier(
onSuccess: () => print('reCAPTCHA Completed!'),
onError: (FirebaseAuthException error) => print(error),
onExpired: () => print('reCAPTCHA Expired!'),
);
我想通过使用 firebase 发送 OTP 来实现 phone 验证,该怎么做? .我已经尝试在 github 中关注此线程,但没有用它没有帮助,signInwithphoneNumber 仅登录用户而不通过发送 SMS OTP 代码验证用户,如何解决这个问题?
Github 线程 link:https://github.com/flutter/flutter/issues/46021
当我执行时抛出以下错误:
Error: UnimplementedError: verifyPhoneNumber() is not supported on the web. Please use
`signInWithPhoneNumber` instead.
有人可以帮我吗!!!
你必须使用
FirebaseAuth auth = FirebaseAuth.instance;
// Wait for the user to complete the reCAPTCHA & for an SMS code to be sent.
ConfirmationResult confirmationResult = await auth.signInWithPhoneNumber('+44 7123 123 456');
然后这个来验证
UserCredential userCredential = await confirmationResult.confirm('123456');
您还可以根据自己的使用添加RecaptchaVerifier,例如
ConfirmationResult confirmationResult = await auth.signInWithPhoneNumber('+44 7123 123 456', RecaptchaVerifier(
container: 'recaptcha',
size: RecaptchaVerifierSize.compact,
theme: RecaptchaVerifierTheme.dark,
));
您还可以编辑验证码
RecaptchaVerifier(
onSuccess: () => print('reCAPTCHA Completed!'),
onError: (FirebaseAuthException error) => print(error),
onExpired: () => print('reCAPTCHA Expired!'),
);