仅当您提供测试电话号码时,Flatter Firebase身份验证才起作用

仅当您提供测试电话号码时,Flatter Firebase身份验证才起作用,firebase,flutter,firebase-authentication,Firebase,Flutter,Firebase Authentication,我的代码正在工作,但它仅验证Firebase身份验证中给出的测试电话号码 当我尝试使用其他号码时,会直接转到PhoneVerificationFailed(),这是我从该方法获得的异常消息:- 错误消息 电话号码验证失败。代码:firebaseAuth。消息:此应用未被授权使用Firebase身份验证。请验证Firebase控制台中是否配置了正确的包名和SHA-1。[应用程序验证失败] 请看一看,并分享你的想法,可能是我做了一些错误 // Example code of how to ve

我的代码正在工作,但它仅验证Firebase身份验证中给出的测试电话号码

当我尝试使用其他号码时,会直接转到PhoneVerificationFailed(),这是我从该方法获得的异常消息:-

错误消息

电话号码验证失败。代码:firebaseAuth。消息:此应用未被授权使用Firebase身份验证。请验证Firebase控制台中是否配置了正确的包名和SHA-1。[应用程序验证失败]

请看一看,并分享你的想法,可能是我做了一些错误


  // Example code of how to verify phone number
  void _verifyPhoneNumber() async {
    setState(() {
      _message = '';
    });
    final PhoneVerificationCompleted verificationCompleted =
        (AuthCredential phoneAuthCredential) {
      _auth.signInWithCredential(phoneAuthCredential);
      setState(() {
        _message = 'Received phone auth credential: $phoneAuthCredential';
      });
    };

    final PhoneVerificationFailed verificationFailed =
        (AuthException authException) {
      setState(() {
        _message =
            'Phone number verification failed. Code: ${authException.code}. Message: ${authException.message}';
      });
    };

    final PhoneCodeSent codeSent =
        (String verificationId, [int forceResendingToken]) async {
      widget._scaffold.showSnackBar(const SnackBar(
        content: Text('Please check your phone for the verification code.'),
      ));
      _verificationId = verificationId;
    };

    final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
        (String verificationId) {
      _verificationId = verificationId;
    };

    await _auth.verifyPhoneNumber(
        phoneNumber: _phoneNumberController.text,
        timeout: const Duration(seconds: 5),
        verificationCompleted: verificationCompleted,
        verificationFailed: verificationFailed,
        codeSent: codeSent,
        codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);
  }





  // Example code of how to sign in with phone.
  void _signInWithPhoneNumber() async {
    final AuthCredential credential = PhoneAuthProvider.getCredential(
      verificationId: _verificationId,
      smsCode: _smsController.text,
    );
    final FirebaseUser user =
        (await _auth.signInWithCredential(credential)).user;
    final FirebaseUser currentUser = await _auth.currentUser();
    assert(user.uid == currentUser.uid);
    setState(() {
      if (user != null) {
        _message = 'Successfully signed in, uid: ' + user.uid;
      } else {
        _message = 'Sign in failed';
      }
    });
  }


如果你们需要完整的代码,请评论,我将分享完整的代码,然后在Firebase端未完成SHA-1配置,一旦完成SHA-1配置,它将开始完美运行

检查此链接以配置SHA-1