Firebase 电话身份验证在发布模式下不起作用

时间:2021-07-08 19:17:38

标签: firebase flutter firebase-authentication

我在我的 Flutter 应用中使用 Firebase 电话身份验证。 电话身份验证在调试模式下工作正常,但在发布模式下它不起作用并且错误也显示为空。 我已经尝试了重复问题中提到的所有解决方案并尝试了

  • 添加版本 SHA1 和 SHA256
  • 已启用设备检查器 API

还是不行

Future<void> sendCode() async {
    setState(() {
      showLoading = true;
    });

    await _auth.verifyPhoneNumber(
      phoneNumber: _countryCode + phoneController.text,
      verificationCompleted: (phoneAuthCredential) async {
        setState(() {
          showLoading = false;
        });
      },
      verificationFailed: (FirebaseAuthException e) async {
        setState(() {
          showLoading = false;
        });
        _scaffoldKey.currentState.showSnackBar(
            SnackBar(content: Text(e.message)));
        Fluttertoast.showToast(
            msg: e.message,
            toastLength: Toast.LENGTH_SHORT,
            gravity: ToastGravity.CENTER,
            timeInSecForIosWeb: 1,
            backgroundColor: Colors.red,
            textColor: Colors.white,
            fontSize: 16.0
        );
        print(e.message);
      },
      codeSent: (verificationId, resendingToken) async {
        setState(() {
          showLoading = false;
          Navigator.push(context, MaterialPageRoute(builder: (context)=> VerifyPage(verificationId,_countryCode.toString()+phoneController.text)));
          this.verificationId = verificationId;
        });
      },
      codeAutoRetrievalTimeout: (verificationId) async {},
    );
  }

0 个答案:

没有答案