小编Mor*_*ish的帖子

如何使用 firebase_auth(电话身份验证)在 Flutter 应用程序中添加短信自动验证?

在我的 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)

dart firebase-authentication flutter

5
推荐指数
1
解决办法
8456
查看次数

标签 统计

dart ×1

firebase-authentication ×1

flutter ×1