2
我試圖從iOS中的Swift用戶取消鏈接電子郵件/密碼驗證。我讀過the documentation,並設法鏈接和取消連接Facebook身份驗證,沒有任何問題。但是,成功鏈接電子郵件/密碼憑證後,providerData
對象爲零。該providerID
是「火力地堡」,但是當我傳遞到取消鏈接代碼以下錯誤被拋出:從iOS用戶的Firebase取消鏈接電子郵件/密碼驗證
Error Domain=FIRAuthErrorDomain Code=17016 "User was not linked to an account with the given provider." UserInfo={NSLocalizedDescription=User was not linked to an account with the given provider., error_name=ERROR_NO_SUCH_PROVIDER}
我使用取消鏈接代碼:
let providerId = (FIRAuth.auth()?.currentUser?.providerID)!
print("Trying to unlink:",providerId) // providerId = "Firebase"
FIRAuth.auth()?.currentUser?.unlinkFromProvider(providerId) { user, error in
if let error = error {
print("Unlink error:", error)
} else {
// Provider unlinked from account successfully
print("Unlinked...user.uid:", user!.uid, "Anonymous?:", user!.anonymous)
}
}
閱讀文檔和已經得到了它在Facebook上工作,我期望providerData數組在電子郵件驗證後填充一些東西。所以我的鏈接代碼是錯誤的(它不會拋出錯誤,似乎工作正常)?
我的鏈接代碼:
let credential = FIREmailPasswordAuthProvider.credentialWithEmail(email, password: password)
FIRAuth.auth()?.currentUser!.linkWithCredential(credential) { (user, error) in
if user != nil && error == nil {
// Success
self.success?(user: user!)
dispatch_async(dispatch_get_main_queue(), {
self.dismissViewControllerAnimated(true, completion: nil)
if type == "new" {
print("New user logged in...")
}
if type == "existing" {
print("Existing user logged in...")
}
})
} else {
print("Login error:",error)
self.showOKAlertWithTitle("Login Error", message: error!.localizedDescription)
}
}
的我怎麼能修改我的做法任何指針將是巨大的。