Почему мой код проверки подлинности телефона Firebase не работает? - PullRequest
0 голосов
/ 16 октября 2019

Я скопировал и изменил некоторые фрагменты кода, чтобы сделать аутентификацию пользователя по номеру телефона. В первый раз, когда я ввел свой номер телефона, мне прислали код, и все работало просто отлично. Однако любые будущие попытки не сработали вообще.

Я уже ввел код SHA-1, и имя пакета также является правильным.

String verificationId;
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;

/// Sends the code to the specified phone number.
  Future<void> _sendCodeToPhoneNumber() async {
    final PhoneVerificationCompleted verificationCompleted = (AuthCredential user) {
      setState(() {
          print('Inside _sendCodeToPhoneNumber: signInWithPhoneNumber auto succeeded: $user');
      });
    };

    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 " + "$vorwahl$handynummer");
    };

    final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
        (String verificationId) {
      this.verificationId = verificationId;
      print("time out");
    };

     await FirebaseAuth.instance.verifyPhoneNumber(
        phoneNumber: '$vorwahl$handynummer',
        timeout: const Duration(seconds: 5),
        verificationCompleted: verificationCompleted,
        verificationFailed: verificationFailed,
        codeSent: codeSent,
        codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);
  }
W/BiChannelGoogleApi( 4243): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak@b0b2b7f
I/FirebaseAuth( 4243): [FirebaseAuth:] Loading module via FirebaseOptions.
I/FirebaseAuth( 4243): [FirebaseAuth:] Preparing to create service connection to gms implementation
I/HwSecImmHelper( 4243): mSecurityInputMethodService is null
I/flutter ( 4243): Phone number verification failed. Code: firebaseAuth. Message: This app is not authorized to use Firebase Authentication. Please verifythat the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed ]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...