第二个参数applicationverifier必须是firebase.auth.applicationverifier的实现

问题描述 投票:0回答:1

第二个参数applicationverifier必须是firebase.auth.applicationverifier的实现

 .auth()
  .signInWithPhoneNumber(phoneNumber, appVerifier)
  .then(function(confirmationResult) {
    // SMS sent. Prompt user to type the code from the message, then sign the
    // user in with confirmationResult.confirm(code).
    window.confirmationResult = confirmationResult;
    //
    alert("SMS sent");
  })
  .catch(function(error) {
    // Error; SMS not sent
    // ...
    alert("Error ! SMS not sent");
  });



 initReCaptcha() {
setTimeout(() => {
  let vm = this;
  window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier(
    "recaptcha-container",
    {
      size: "invisible",
      callback: function(response) {
        // reCAPTCHA solved, allow signInWithPhoneNumber.
        // ...
      },
      "expired-callback": function() {
        // Response expired. Ask user to solve reCAPTCHA again.
        // ...
      }
    }
  );
  //
  this.appVerifier = window.recaptchaVerifier;
}, 1000);
}

created() {
  this.initReCaptcha();
}

我将应用程序验证程序设置为第二个参数,但会产生错误,我该怎么办

javascript firebase react-native firebase-authentication
1个回答
0
投票
[调用时很可能appVerifier尚未初始化:

signInWithPhoneNumber(phoneNumber, appVerifier)

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.