如何使用firebase快速合并自定义登录(电子邮件)与Facebook登录 [英] How to merge custom login (Email) with Facebook login in swift using firebase
问题描述
链接这解释了我试图解决的情况。我正在寻找任何代码示例如何做。
在此先感谢。
Firebase实际上相当简单。下面的代码应该工作,我也包括一个链接到描述该过程的文档。
let credential = FacebookAuthProvider.credential withAccessToken:
FBSDKAccessToken.current()。tokenString)
$ b $ if let user = FIRAuth.auth()?currentUser {
user.link(with:credential){ ,错误)in
//在帐户被链接之后执行任何操作
$ b $ $
$ b 以下是关于此主题的Firebase文档的链接:
https://firebase.google.com/docs/auth/ios/account-linking
I am implementing custom (Email) and Facebook login authentication in swift using Firebase. Since, I enabled multiple accounts per email address, a same user using his email as well as his facebook account can sign in to the app. Firebase considers them as two separate users, but I want to merge them as long as the email address is same. I found this
link from the Facebook site which explain the scenario which i am trying to solve. I am looking for any code samples on how to do.
Thanks in advance.
解决方案 This is actually quite simple with Firebase. The below code should work and I have also included a link to the documentation describing the process.
let credential = FacebookAuthProvider.credential(withAccessToken:
FBSDKAccessToken.current().tokenString)
if let user = FIRAuth.auth()?.currentUser {
user.link(with: credential) { (user, error) in
//perform any actions after the account has been linked
}
}
Here is a link to the Firebase documentation on the subject:
https://firebase.google.com/docs/auth/ios/account-linking
这篇关于如何使用firebase快速合并自定义登录(电子邮件)与Facebook登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!