title: Can't connect to Firebase after connecting to Facebook - In Swift 3
body: <p>Before moving to Swift 3 the user had to log in to the app by Facebook, and then it automatically logged in to your Firebase account. Everything was good, but then I moved to Swift 3. The log in button still exists, but after it asks for permission to log in to Facebook - nothing happens.</p>
  
  <p>Here is my code before moving to Swift 3:</p>
  
  <pre><code>var loginButton: FBSDKLoginButton = FBSDKLoginButton()
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          loginButton.hidden = true
          FIRAuth.auth()?.addAuthStateDidChangeListener { auth, user in
              if let user = user {
                  // User is signed in.
                  currentEmail = user.email!
                  print("DONE")
                  NSNotificationCenter.defaultCenter().postNotificationName("dontShowLogInView", object: nil)
                  } else {
                  // No user is signed in.
                  self.loginButton.center = self.view.center
                  self.loginButton.readPermissions = ["public_profile", "email", "user_friends"]
                  self.loginButton.delegate = self
  
                  self.view.addSubview(self.loginButton)
                  self.loginButton.hidden = false
              }
          }
  
          // Optional: Place the button in the center of your view.
  
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
          print("user logged in")
          self.loginButton.hidden = true
          activityIndicator.startAnimating()
          if error != nil {
              self.loginButton.hidden = false
              activityIndicator.stopAnimating()
              print("???")
              //handle errors
          } else if result.isCancelled {
              self.loginButton.hidden = false
              activityIndicator.stopAnimating()
              let loginManager = FBSDKLoginManager()
              loginManager.logOut()
              //handle cancel
              print("canceled")
          } else {
              let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)
              FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
                  print("user logged to firebase app")
  
              }
          }
  
  
      }
  
      func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
          print("user logged out")
      }
  </code></pre>
  
  <p>And this is the code after moving to Swift 3:</p>
  
  <pre><code>var loginButton: FBSDKLoginButton = FBSDKLoginButton()
  
  override func viewDidLoad() {
      super.viewDidLoad()
      //getFBUserData()
      loginButton.isHidden = true
      FIRAuth.auth()?.addStateDidChangeListener { auth, user in
          if let user = user {
              // User is signed in.
              currentEmail = user.email!
              print("DONE")
              print(currentEmail)
              NotificationCenter.default.post(name: Notification.Name(rawValue: "dontShowLogInView"), object: nil)
              } else {
              // No user is signed in.
              self.loginButton.center = self.view.center
              self.loginButton.readPermissions = ["public_profile", "email", "user_friends"]
              self.loginButton.delegate = self
  
              self.view.addSubview(self.loginButton)
              self.loginButton.isHidden = false
          }
      }
  
      // Optional: Place the button in the center of your view.
  
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  func loginButton(loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: NSError!) {
      print("user logged in")
      self.loginButton.isHidden = true
      activityIndicator.startAnimating()
      if error != nil {
          self.loginButton.isHidden = false
          activityIndicator.stopAnimating()
          print("???")
          //handle errors
      } else if result.isCancelled {
          self.loginButton.isHidden = false
          activityIndicator.stopAnimating()
          let loginManager = FBSDKLoginManager()
          loginManager.logOut()
          //handle cancel
          print("canceled")
      } else {
          let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
          FIRAuth.auth()?.signIn(with: credential) { (user, error) in
              print("user logged to firebase app")
  
          }
      }
  
  
  }
  
  func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) {
      print("user logged out")
  }
  </code></pre>