I am trying to make the following things:
- Sign in with number and password. (Connect email/number)
- Use one textfield for email/ number when the user can type one of the options and firebase will login in to that user account
I looked up at Firebase docs but there was not no mention about having Phone Number / Password auth.
For example, I signed up: email: SOME_MAIl password: SOME_PASSWORD number: SOME_NUMBER I want to make something like this
If numberAuth { Auth.auth.signIn(withNumber: number, password: password ) } else { Auth.auth.signIn(email: email, password: password ) } I found out that I have to customize firebase auth but I don't have an idea how to custom that. How that should be done?
P.S.: My idea is similar to this question Firebase Authentication connect Email with Phone
In the image below the idea is illustrated
Here is my code:
func signIn() { if let password = passwordValue.text, let email = emailValue.text { Auth.auth().signIn(withEmail: email, password: password ) { [weak self] authResult, error in if let e = error { print(e) let alert = Service.createAlertController(title: "Error", message: e.localizedDescription) self?.present(alert, animated: true,completion: nil) } else { let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewController(identifier: "main") vc.modalPresentationStyle = .overFullScreen self?.present(vc, animated: true) } } } } 