【问题标题】:Firebase Phone Authentication error in React Native CodeReact Native 代码中的 Firebase 电话身份验证错误
【发布时间】:2020-05-21 06:57:24
【问题描述】:

我正在尝试构建一个 React Native 应用程序和 firebase 身份验证。我收到错误:

RecaptchaVerifier 仅在支持 DOM 的浏览器 HTTP/HTTPS 环境中受支持

auth
      .signInWithPhoneNumber(number, appVerifier)) // <- this is where captcha is added
      .then((result) => {
        this.setState({ confirm: result });
        this.setState({ buttonText: "Verify OTP" });
        this.setState({ isLoading: false });
      })
      .catch((err) => {
        console.log(`Error in phone auth: ${err}`);
      });

我使用的firebase版本是"react-native-firebase": "^5.6.0" 当我删除第二个参数时,它会给出一个错误,指出需要两个参数,找到一个

【问题讨论】:

    标签: firebase react-native firebase-authentication react-native-android react-native-firebase


    【解决方案1】:

    您确定您使用的是 5.X.X 版本的react-native-firebase phone auth。您可以从方法中跳过 appverifier,而是使用react-native-firebase 中的以下方法。它会自动打开一个窗口来验证应用程序和recaptha。

    firebase.auth().signInWithPhoneNumber(phoneNumber)
    .then(confirmResult => // save confirm result to use with the manual verification code)
    .catch(error => /error);
    

    【讨论】:

    • 是的,我的 firebase 版本是 5.6.0,当我删除 appVerifier 时,它说需要 2 个参数,但有一个
    • @SandipSingh - 你有想过这个吗?
    • @ChrisEaheart - 是的,我更新了我的 firebase 版本,它就像一个魅力,以防你需要任何让我知道的帮助
    • @SandipSingh - 我的 package.json 有以下内容 - 你指的是不同的包吗?: "@react-native-firebase/app": "^6.7.1", "@react- native-firebase/auth": "^6.7.1", "@react-native-firebase/messaging": "^6.7.1",
    • 之前我使用的是版本 5,现在我使用的是版本 6,这是当前最新版本,它不会引发任何问题
    猜你喜欢
    • 2020-10-04
    • 1970-01-01
    • 2017-10-17
    • 2018-01-19
    • 2018-02-21
    • 2016-06-12
    • 2021-11-30
    • 1970-01-01
    • 2020-01-28
    相关资源
    最近更新 更多