firebase / firebase/snippets-web

Recaptcha Verifier throws an error

Open
#346 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
802
Forks
285
PR merge metrics
No merged PRs in 30d

Description

I'm pretty sure i'm doing it right, but the RecaptchaVerifier is causing this error: TypeError: Cannot read property 'prototype' of undefined, js engine: hermes, it is written in react native:
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View, Button } from "react-native";
import { auth } from "./firebaseConfig";
import { useRef } from "react";
import { RecaptchaVerifier, signInWithPhoneNumber } from "firebase/auth";

export default function App() {
let phone = "+639612895391";
const myRef = useRef();

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

const requestOtp = () => {
generateRecaptcha();
let appVerifier = window.recaptchaVerifier;
signInWithPhoneNumber(auth, phone, 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;
// ...
console.log("success");
})
.catch((error) => {
// Error; SMS not sent
// ...
console.log(error);
});
};
return (

Open up App.js to start working on your app!




);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
config:
import { getAuth } from "firebase/auth";
import { initializeApp } from "firebase/app";

const firebaseConfig = {
apiKey: "AIzaSyCCyEg_qMyEl-9y55DjJSlcEs3JJIbzLxc",
authDomain: "authentication-4e981.firebaseapp.com",
projectId: "authentication-4e981",
storageBucket: "authentication-4e981.appspot.com",
messagingSenderId: "1046042873971",
appId: "1:1046042873971:web:d4d737ed3fc47757929a06",
};

const app = initializeApp(firebaseConfig);

export const auth = getAuth(app);

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.