Search code examples
iosswiftfirebaseemail-verification

How do I verify an email address to a certain user in ios swift?


I made a register form with a email address text field and such, so how do I verify that the email address belongs to the person. Could I make a code that is emailed to the user's email but how do I send emails in Xcode? Or is there some other way to do it with Firebase?


Solution

  • After you've created a user with their email and password, if there are no errors you send them a verification email.

    import FirebaseAuth  
    
    Auth.auth().currentUser?.sendEmailVerification
            {
                (error) in
                if error != nil
                {
                    print(error!.localizedDescription)
                    return
                }
                else
                {
                    //CHECK INBOX FOR CONFIRMATION LINK
                }
            }