skip to Main Content

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


  1. Chosen as BEST ANSWER

    this is the way to works with my code:

     const auth = getAuth(app);
          const appVerifier = recaptchaVerifier.current;
          const fullPhoneNumber = `+${countryCallingCode}${phoneNumber.replace(
            /^0+/,
            ""
          )}`;
    
          const confirmResult = await signInWithPhoneNumber(
            auth, 
            fullPhoneNumber,
    
            appVerifier
          );
    

  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search