'how to verify user email in firebase react native(Expo)

In my application user authentication is done every thing is working fine but I want implement user email verification feature in my app I am done with user authentication and storing user details in Firestore

my signup method code :


     const onRegister = async (email, password, username) => {
    try {
      const authUser = await firebase
        .auth()
        .createUserWithEmailAndPassword(email, password);  
    db.collection("users").add({
        owner_uid: authUser.user.uid,
        displayname: username,
        email: authUser.user.email,
        photoURL: await getrandompicture(),
      });

      await firebase.auth().currentUser.updateProfile({
        displayName: username,
        photoURL: await getrandompicture(),
      });
    } catch (error) {
      Alert.alert(error.message);
    }
  };

my authnavigation :

const Authnavigation = () => {
  const [currentUser, setcurrentUser] = useState(null);
  const userHandler = (users) =>
    users ? setcurrentUser(users) : setcurrentUser(null);
  useEffect(
    () => firebase.auth().onAuthStateChanged((user) => userHandler(user)),
    []
  );
  return (
    <>
      {currentUser ? (
        <Singninstack userID={currentUser.uid} />
      ) : (
        <Signoutstack />
      )}
    </>
  );
};

export default Authnavigation;


Solution 1:[1]

You can call sendEmailVerification right after creating the user.

await authUser.user.currentUser.sendEmailVerification()
  .then(() => {
    // Email verification sent!
    // ...
  });

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharmaraj