Berk Kaya Berk Kaya - 3 months ago 100x
Swift Question

Firebase Facebook login check if user exist

I have an facebook login system which works with firebase but I want to check if user exist on my firebase (i don't want to add it, just want to make sure if he exist because I want to redirect user to another page to complete its profile, once its done I'll want to send it to firebase).

I just need to check if user exist on my db. Here is the code that I try but it returns nil error and it automatically add user to firebase.

let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)

FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
// ...



You can use reauthenticateWithCredential method to check user is exist or not.

Check this Doc. , section -> Re-authenticate a user

let user = FIRAuth.auth()?.currentUser
var credential: FIRAuthCredential

// Prompt the user to re-provide their sign-in credentials

user?.reauthenticateWithCredential(credential) { error in
  if let error = error {
    // An error happened.
  } else {
    // User re-authenticated.

If user re-authenticated successfully that means user is existed...