Background:
I am developing an IOS app using firebase as backend. There are 3 authentication: 1:password and email 2:FaceBook 3:Google
I have checked the op
When you get the credential already exists error, you already have the email at that point, you then call fetchProvidersForEmail
with that email which will lookup the provider IDs associated with that email. You then sign in the user with one of those providers. After you finish sign-in with the existing account, you call linkWithCredential:completion:
with the original credential that caused the error to occur. This causes the accounts to link. The next time the user tries to sign in, they will be able to sign in to the same user with either provider.
Check FirebaseUI-iOS which already takes care of the whole flow for you. You can also check there source code to see how they handle such situations: https://github.com/firebase/FirebaseUI-iOS