在我的 flutter 应用程序中,我使用Firebase电话身份验证进行登录。总而言之,它完美地工作。通过使用我当前的代码,我必须在收到代码时明确添加短信代码。
如何在我的 Flutter 应用程序中自动进行此短信验证?
Future<void> _sendCodeToPhoneNumber() async {
final String phone = country + phoneNumberController.text;
final PhoneVerificationCompleted verificationCompleted =
(AuthCredential credential) {
setState(() {
print(
'Inside _sendCodeToPhoneNumber: signInWithPhoneNumber auto succeeded: $credential');
});
};
final PhoneVerificationFailed verificationFailed =
(AuthException authException) {
setState(() {
print(
'Phone number verification failed. Code: ${authException.code}. Message: ${authException.message}');
});
};
final PhoneCodeSent codeSent =
(String verificationId, [int forceResendingToken]) async {
this._verificationId = verificationId;
print("code sent to " + phone);
setState(() { …
Run Code Online (Sandbox Code Playgroud)