Flutter Firebase 电话认证时为什么没有短信代码

时间:2021-04-04 12:29:39

标签: firebase flutter firebase-authentication

我从github上拿了代码来检查电话验证是否有效。我正在尝试向俄罗斯号码发送短信代码,但没有收到。 Firebase 完全连接并且 SHA-1 也是。 ``

_verifyPhone() async {
    await FirebaseAuth.instance.verifyPhoneNumber(
        phoneNumber: '+7${widget.phone}',
        verificationCompleted: (PhoneAuthCredential credential) async {
          await FirebaseAuth.instance
              .signInWithCredential(credential)
              .then((value) async {
            if (value.user != null) {
              Navigator.pushAndRemoveUntil(
                  context,
                  MaterialPageRoute(builder: (context) => Home()),
                      (route) => false);
            }
          });
        },
        verificationFailed: (FirebaseAuthException e) {
          print(e.message);
        },
        codeSent: (String verficationID, int resendToken) {
          setState(() {
            _verificationCode = verficationID;
          });
        },
        codeAutoRetrievalTimeout: (String verificationID) {
          setState(() {
            _verificationCode = verificationID;
          });
        },
        timeout: const Duration(seconds: 30));
  }

``

0 个答案:

没有答案