vkrishnan23 vkrishnan23 -5 years ago 107
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 Source

Unwrap the optional:

if let user = currUserID{
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download