vkrishnan23 vkrishnan23 - 5 months ago 22
Swift Question

Firebase wrapping user information with an "Optional()" wrapper

My code to get a current user's email address is:

let currUserId = FIRAuth.auth()?.currentUser?.email
currUser = "Logged in as User: \(currUserId)"


The result is shown like this:

Logged in as User: Optional("email")

Is there any way to eliminate this wrapper. I seem to be having this same issue when Firebase pushes my UID to my database, as it likes to wrap it in an Optional("uid") wrapper.

Answer

Unwrap the optional:

if let user = currUserID{
print(user)
}