部署后,Firebase 电话身份验证不起作用


我使用 firebase

创建反应应用程序我使用 firebase 电话身份验证创建用户帐户,但问题是 firebase 电话身份验证本地运行,但我部署了应用程序 firebase,所以我的手机身份验证功能在 react 中不起作用 这是代码..

var phoneNumber = th.state.Phone;
            var appVerifier = window.recaptchaVerifier;
            firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
              .then(function (confirmationResult) {
                window.confirmationResult = confirmationResult;
                // conform = confirmationResult;
                console.log('result', confirmationResult);
              })
              .then(() => {
                th.setState({ status: 'hide', modalOpen: true })
              }).catch(function (error) {
                // Error; SMS not sent
                th.setState({ status: 'hide' })
                console.log('err',error);
                // ...
              })
componentDidMount() {
    window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in', {
      'size': 'invisible',
      'callback': function (response) {
        // reCAPTCHA solved, allow signInWithPhoneNumber.
        //    this.onSignInSubmit();
        console.log('res', response)
      }
    });
    //  window.recaptchaVerifier.render().then(function (widgetId) {
    //    window.recaptchaWidgetId = widgetId;
    //    });
  }
您需要

在部署到 Firebase 项目后添加链接网站。这对我来说是工作。https://i.stack.imgur.com/6YOHp.png

问题是Firebase找不到OTP,因为我部署了另一个Firebase项目的反应应用程序,所以如果您使用的是Firebase OTP,那么在同一项目上进行部署

最新更新