Databases M3 L3 FUIEmailAuth

Hey everyone,
I’m having an issue with my login. Hopefully this is clear. (I’ve read the related posts and tried to implement the suggested changes, but I am encountering 2 issues:

  1. if I create my code exactly as Chris has instructed, I get an empty login screen after tapping on the login button. 2) if I add the FUIEmailAuth code, I get an error "Use of unresolved identifier ‘FUIEmailAuth’

I’ve added the FirebaseUI/Email pod, I import the FirebaseAuth, but that hasn’t helped.
I’m not sure what to do next…

//
// LoginViewController.swift
// Photo App
//
// Created by Mike Nelson on 1/25/20.
// Copyright © 2020 CIC Solutions. All rights reserved.
//

import UIKit
import FirebaseAuth
import FirebaseUI

class LoginViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

@IBAction func loginTapped(_ sender: UIButton) {
    
    // Create Firebase Auth UI object
    let authUI = FUIAuth.defaultAuthUI()
    
    // Check that it isn't nil
    //if let authUI = authUI {
        
    guard authUI != nil else{
        return
    }
    // Set the login view controller as the delegate
    authUI?.delegate = self
    authUI?.providers = [FUIEmailAuth()]  <`*--- HERE IS where the error comes in*`
        
    // Create a Firebase auth pre build UI view controller
    let authViewController = authUI!.authViewController()
    
    // Present it
    present(authViewController, animated: true, completion: nil)
        
   // }
        
}

}

extension LoginViewController: FUIAuthDelegate {

func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?) {
    
    // Check if an error occurred
    guard error == nil else {
        print("an error has happened")
        return
    }
    
    // Get the user
    let user = authDataResult?.user
    
    // Check if user is nil
    if let user = user {
        
        // this means that we have a user, now check if they have a profile
        UserService.getUserProfile(userID: user.uid) { (u) in
            
            if u == nil {
                // No profile, go to Profile Controller
                self.performSegue(withIdentifier: Constants.Segue.profileViewController, sender: self)
            }
            else {
                // This user has a profile go to Tab Controller
                let tabBarVC = self.storyboard?.instantiateViewController(withIdentifier: Constants.Storyboard.tabBarController)
                
                self.view.window?.rootViewController = tabBarVC
                self.view.window?.makeKeyAndVisible()
            }
            
        }
        
    }
    
}

}

OK, so I’ve gotten rid of the error message on FUIEmailAuth - something weird about xcode, I guess it had something in memory and kept giving me the error. I deleted the code rebuilt and then added it back in and it worked. Now everything works with that call. I would be interested in how Chris’s project works though. I downloaded his without the FUIEmailAuth, and it works fine but I can’t figure out the differences between his and mine (without the FUIEmailAuth)…

1 Like

Hey I have the exact same issue but it won’t fix… Do you have any tipps?

hello try to make a new thread and post more details of your problem