我正在尝试实现FIrebase UI电话号码身份验证,但是在验证电话号码后不调用委托方法。有什么原因吗?
class Login: UIViewController, FUIAuthDelegate {
let authUI = FUIAuth.defaultAuthUI()
override func viewDidAppear(_ animated: Bool) {
let phoneProvider = FUIPhoneAuth(authUI: authUI!)
authUI!.isSignInWithEmailHidden = true
authUI!.providers = [phoneProvider]
phoneProvider.signIn(withPresenting: self, phoneNumber: nil)
}
//this method does not work either... it is not called
func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?) {
print("user is \(authDataResult!.user.email)")
print("err is \(error?.localizedDescription)")
guard error == nil else {
print(error)
return
}
}
}
答案 0 :(得分:0)
我忘了指派自己作为authUI
的代表
override func viewDidAppear(_ animated: Bool) {
authUI?.delegate = self
let phoneProvider = FUIPhoneAuth(authUI: authUI!)
authUI!.isSignInWithEmailHidden = true
authUI!.providers = [phoneProvider]
phoneProvider.signIn(withPresenting: self, phoneNumber: nil)
}