Phone Verification Code... NEED HELP

Hey all!

Been having trouble with my Swift code creating a phone verification app.
I have a Verify Phone Number View Controller and a Verification View Controller.
The code on the Verify Phone Number View Controller works fine but the Verification View Controller I’m having problems with, please help! Please see code below!

I am getting the error -> Value of type ‘AuthDataResult’ has no member ‘phoneNumber’ & Value of type ‘AuthDataResult’ has no member ‘providerData’

Don’t know whats going on.

@IBAction func verifyTapped(_ sender: Any) {
let defaults = UserDefaults.standard
let credential: PhoneAuthCredential = PhoneAuthProvider.provider().credential(withVerificationID: defaults.string(forKey: “authVerificationID”)!, verificationCode: otpCodeTextField.text!)
Auth.auth().signIn(with: credential) { (user, error) in
if error != nil {
print(“error: (String(describing: error?.localizedDescription))”)
} else {

                  print("Phone number: \(String(describing: user?.phoneNumber))")
                   let userInfo = user?.providerData[0]
                   print("Provider ID: \(String(describing: userInfo?.providerID))")
                   self.performSegue(withIdentifier: "logged", sender: Any?.self)
                   
               }
           }
       }

       override func didReceiveMemoryWarning() {
           super.didReceiveMemoryWarning()
           // Dispose of any resources that can be recreated.
       }

Hi KC,

Although you have not said so, I assume that you are using Firebase Authentication and you are trying to setup authentication by Phone number. Is that the case?

Hi Chris,

Yes I am using FirebaseAuth.

I’ve never used Authentication by PhoneNumber so I can’t advise. As an observation, it would seem to me that Authenticating with Email and Password is a much easier approach but that’s your call.

Make sure that in your VerificationViewController that you have all the necessary import statements to support your code.

Do you know how to do a SMS verification?
The idea is to authenticate with email/password and then to verify the users identity with SMS verification code.

No I don’t know how that is done.

Maybe someone else might chime in with a suggestion.