iosswiftfirebasefirebase-authenticationpassword-less

Link phone provider with email provider in Firebase (Swift)


How can one link the phone provider with the email provider in authenticated users section from Firebase?

Whenever I try to log in with the email, it then removes the phone number from the identifier section and then I try to log in with the phone number it creates a new user with a different UID.

I am looking for a solution in Swift that would have both phone and email as providers, any advice?

Firebase Authentication


Solution

  • You can link multiple Auth providers as explained in this link

    // If email & password
    // let credential = EmailAuthProvider.credential(withEmail: email, password: password)
    // If email link
    let credential = EmailAuthProvider.credential(withEmail: email, link: link)
    Auth.auth().currentUser.link(with: credential) { (authResult, error) in
      // ...
    }