Firebase otp recaptcha错误:无法读取未定义的属性(阅读“appVerificationDisabledForTesting”)

soat7uwm  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(125)

我使用firebase生成otp,我得到一个关于appVerificationDisabledForTesting未定义的错误。

recaptcha_verifier.ts:114 Uncaught TypeError: Cannot read properties of undefined (reading 'appVerificationDisabledForTesting')
    at new RecaptchaVerifier (recaptcha_verifier.ts:114:1)
    at generateRecaptcha (Home.js:123:1)
    at handleSend (Home.js:139:1)

字符串
这是我使用的代码

const handleSend = (event) => {
    event.preventDefault();

    generateRecaptcha();
    let appVerifier = window.recaptchaVerifier;
    signInWithPhoneNumber(auth, phoneNumber, appVerifier)
      .then((confirmationResult) => {
        // SMS sent. Prompt user to type the code from the message, then sign the
        // user in with confirmationResult.confirm(code).
        window.confirmationResult = confirmationResult;
      })
      .catch((error) => {
        // Error; SMS not sent
        console.log(error);
      });
  };


错误来自generateRecaptcha();

const generateRecaptcha = () => {
    window.recaptchaVerifier = new RecaptchaVerifier(
      "recaptcha",
      {
        size: "invisible",
        callback: (response) => {
          // reCAPTCHA solved, allow signInWithPhoneNumber.
          // ...
        },
      },
      auth
    );
  };

5fjcxozz

5fjcxozz1#

“firebase”:“^9.4.1”
将firebase版本更改为9. 4. 1,它将工作,我也陷入了这个错误,并一直在寻找解决方案,这是我现在得到的唯一解决方案

相关问题