user9585671
user9585671

Reputation:

verifiy email with firebase swift xcode

Im trying to see if an email has been verified by firebase then call code but i can't get emailVerified to work/ i get the error no member emailVerified

has it been changed / can anyone give me the sample code?

my related code below:

import FirebaseAuth
import Firebase
import FirebaseDatabase

guard let uid = Auth.auth().currentUser?.uid else { return }


    if uid.emailVerified == true {

print("working")
 }

Upvotes: 0

Views: 101

Answers (1)

DoesData
DoesData

Reputation: 7047

First you need to send the email verification. You can do that like this:

Auth.auth().currentUser?.sendEmailVerification { (error) in
  // ...
}

You can check if a user has verified their email like this:

if let user = Auth.auth().currentUser {
    if user.isEmailVerified {
        // Do something
    }
}

Documentation

Upvotes: 1

Related Questions