I added firebase auth to my app, however, I don't think the code is right. I just wanted someone to double check it for me. I have phone auth, and email/password auth. Here is the code:
//MARK: Phone Verification //Sends code to mobile device @IBAction func sendCode(_ sender: Any) { PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber.text!, uiDelegate: nil) { (verificationID, error) in if let error = error { print(error as Any) return } // Sign in using the verificationID and the code sent to the user // ... UserDefaults.standard.set(verificationID, forKey: "authVerificationID") } } //Checks verification code @IBAction func enterverificationCode(_ sender: Any) { let verificationID = UserDefaults.standard.string(forKey: "authVerificationID") let credential = PhoneAuthProvider.provider().credential( withVerificationID: verificationID!, verificationCode: verificationCode.text!) Auth.auth().signInAndRetrieveData(with: credential) { (authResult, error) in if error != nil { // ... return } // User is signed in // ... if Auth.auth().currentUser != nil { // User is signed in. // ... } else { // No user is signed in. // ... } } } //MARK: Email/Password Verification //Creates account for email/password verification @IBAction func createEmailPasswordAccount(_ sender: Any) { Auth.auth().createUser(withEmail: email1.text!, password: password1.text!) { (authResult, error) in // ... } } @IBAction func signInEmailPasswordAccount(_ sender: Any) { Auth.auth().signIn(withEmail: email1.text!, password: password1.text!) { (user, error) in // ... if Auth.auth().currentUser != nil { // User is signed in. // ... } else { // No user is signed in. // ... } } } @IBAction func signOut(_ sender: Any) { let firebaseAuth = Auth.auth() do { try firebaseAuth.signOut() } catch let signOutError as NSError { print ("Error signing out: %@", signOutError) } }