电话验证完成后未调用Firebase UI委托方法

时间:2018-10-16 07:47:21

标签: swift firebase firebase-authentication firebaseui

我正在尝试实现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
    }
}


  }

1 个答案:

答案 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)
}