job.answiz.com
  • 15
Votes
name

//

//  varificationCodeViewController.swift

//  phoneAuth

//

//  Created by apple on 8/21/19.

//  Copyright © 2019 apple. All rights reserved.

//

 

import UIKit

import FirebaseAuth

 

class varificationCodeViewController: UIViewController {

 

    @IBOutlet weak var code: UITextField!

    override func viewDidLoad() {

        super.viewDidLoad()

 

        // Do any additional setup after loading the view.

    }

    

    @IBAction func Login(_ sender: UIButton) {

        let defaults = UserDefaults.standard

        let credential: PhoneAuthCredential =  PhoneAuthProvider.provider().credential(withVerificationID: defaults.string(forKey: "authId")!, verificationCode: code.text!)

        Auth.auth().signIn(with: credential, completion: { (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: <#T##Any?#>)

                

                

            }

        

        }

 

}