我无法弄清楚如何在firebase中查看电话号码,我不知道如何让用户保持登录状态。
我尝试了很多代码并没有为我效劳:
class VerifyCodeVC: UIViewController {
@IBOutlet weak var Code: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func Verify(_ sender: Any) {
let defaults = UserDefaults.standard
let credential: PhoneAuthCredential = PhoneAuthProvider.provider().credential(withVerificationID: defaults.string(forKey: "authVID")!, verificationCode: Code.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: "maininf", sender: Any?.self)
}
}
}
}