2017-09-26 23 views
0

在firebase更新之前,此代碼在電子郵件登錄和打印用戶電子郵件時運行良好。 但今天我更新了firebase後,下面的代碼有錯誤。 請善意幫助解決它。swift3 firebase更新並獲取FIRAuth.auth()的錯誤currentUser?.email

override func viewDidLoad() { 
    super.viewDidLoad() 

    // Do any additional setup after loading the view. 
    print(FIRAuth.auth().currentUser?.email) 
} 

將代碼FIRAuth更改爲Auth並運行應用程序之後。 我輸入電子郵件和密碼,然後按登錄按鈕,它顯示以下錯誤。

enter image description here

+0

Auth.auth()currentUser .email – DoesData

+0

@DoesData它不起作用,當運行它的應用程序出現錯誤時 –

+0

是什麼錯誤? – 3stud1ant3

回答

0

這種方式爲我工作:

let email = emailText.text! 
let password = passwordText.text! 

Auth.auth().signIn(withEmail: email, password: password) { (user, error) in 

if error == nil { 

/* user is signed in */ 

} else { 

/* email or password is taken OR error connecting to Firebase */ 

} 

} 

要獲取當前用戶的電子郵件試試這個:?

print(Auth.auth().currentUser?.email as String!)