“expo”的电话认证:“~50.0.6”,“firebase”的电话认证:“^10.8.0”,用于反应本机项目“react-native”:“^0.73.4”,

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

请告诉我如何在展会上实现电话验证

对于网络应用程序,我们使用

import { getAuth, RecaptchaVerifier } from "firebase/auth";

const auth = getAuth();
window.recaptchaVerifier = new RecaptchaVerifier(auth, 'sign-in-button', {
    'size': 'invisible',
    'callback': (response) => {
        reCAPTCHA solved, allow signInWithPhoneNumber.
        onSignInSubmit();
    }
});

但是如果我们尝试在 expo 移动应用程序中使用它,如何获取像登录按钮这样的元素 id?

我试过这个

import auth from "@react-native-firebase/auth";

const signInWithPhoneNumber = async (user) => {
    try {
        const confirmation = await auth().signInWithPhoneNumber("+91" + user);
        if (confirmation) {
            setConfirm(confirmation);
        }
    } catch (error) {
        console.log("Error sending code: ", error)
    }
}
const confirmCode = async () => {
    const userCredential = await confirm.confirm(code);
    const user = userCredential.uer
    console.log(user)
}

我收到错误:

ERROR 错误:您尝试通过调用 firebase.app() 使用未安装在 Android 项目上的 Firebase 模块。
确保您拥有:\

  1. 在“MainApplication.java”文件中导入了“io.invertase.firebase.app.ReactNativeFirebaseAppPackage”模块。

  2. 在 RN“getPackages()”方法列表中添加了“new ReactNativeFirebaseAppPackage()”行。

请参阅 http://invertase.link/android 了解完整的设置说明。, js 引擎:hermes

javascript firebase react-native firebase-authentication expo
1个回答
0
投票

您是否将包添加到

getPackage()
文件中的
MainApplication.java
中,如果没有像下面这样通过,然后尝试

protected List<ReactPackage> getPackages() {
  @SuppressWarnings("UnnecessaryLocalVariable")
  List<ReactPackage> packages = new PackageList(this).getPackages();
  packages.add(new ReactNativeFirebaseAppPackage());
  return packages;
}
© www.soinside.com 2019 - 2024. All rights reserved.