when trying to register with phone number by Firebase phone authentication and using my own number i get this error:
ERROR [TypeError: undefined is not an object (evaluating ‘verifier.verify’)]
here are the necessary codes just just know i used my phone number instead "test number"
import {
getAuth,
createUserWithEmailAndPassword,
verifyPhoneNumber,
PhoneAuthProvider,
signInWithCredential,
onAuthStateChanged,
} from "firebase/auth";
///////////////////////////////////////////////////////
const auth = getAuth();
async function handleVerifyPhoneNumber(phoneNumber) {
try {
const provider = new PhoneAuthProvider(auth);
const confirmation = await provider.verifyPhoneNumber(phoneNumber);
setConfirm(confirmation);
} catch (error) {
console.error(error);
}
}
///////////////////////////////////////////////////////
<Button
title="Verify Phone Number"
onPress={() => handleVerifyPhoneNumber("test Number")}
/>
2
Answers
this is the way to works with my code:
It looks like you are using Firebase Web for this when you should be using the mobile Android and iOS setups. This is the official package for integrating React Native with Firebase – https://rnfirebase.io/. Follow the directions on the site to correctly configure Firebase for your React Native app.