我是Firebase和iOS的新手,我想知道是否有人知道如何鏈接多個oAuth提供程序。我跟着火力地堡文檔,並試圖實現這個功能:在Firebase中鏈接oAuth提供程序iOS
func firebaseSignInWithLink(credential: FIRAuthCredential) {
FIRAuth.auth()?.signIn(with: credential, completion: { (user, error) in
if error != nil {
debugPrint("APP: there has been an error signing into firebase, perhaps another account with same email")
debugPrint("APP: \(error)")
// if existing email, try linking
FIRAuth.auth()?.currentUser?.link(with: credential, completion: { (user, error) in
if error != nil {
debugPrint("APP: there has been an error signing into firebase")
debugPrint("APP: \(error)")
}
else {
debugPrint("APP: successfully signed into firebase")
}
})
}
else {
debugPrint("APP: successfully signed into firebase")
}
})
}
的FIRAuth.auth()?.currentUser?.link
功能不會被調用,儘管上述debugPrint("APP: \(error)")
被調用。因爲這不工作,我不斷收到以下錯誤:「該電子郵件地址已在使用由另一個帳戶\」
可選(錯誤域= FIRAuthErrorDomain代碼= 17007 \的UserInfo = {NSLocalizedDescription =該電子郵件地址已被其他帳戶,ERROR_NAME = ERROR_EMAIL_ALREADY_IN_USE,[email protected]})」
任何幫助將不勝感激謝謝:!d
我正在解決同樣的問題。我還沒有掌握它,但如果你已經有「currentUser」(我很確定你這樣做),你不應該呼叫登錄,因爲該用戶的電子郵件已經與先前登錄的不同IDP相關聯。 ..我們看到的錯誤... – Dewey
我覺得讓我感到困惑的是如果用戶無法通過產生錯誤的oAuth登錄,我們如何獲取currentUser對象。用戶是否必須嘗試所有可能的auth方法,直到他/她成功登錄並獲取currentUser對象,然後再次登錄到oAuth以將其鏈接? :/ – Clement