Firebase Auth - get provider ID

前端 未结 6 919
予麋鹿
予麋鹿 2020-12-15 05:09

I\'m using the following code, to detect auth provider and log out properly

static func logOut() {
    let auth = FIRAuth.auth()!
    let provider = auth.cur         


        
6条回答
  •  攒了一身酷
    2020-12-15 05:21

    Swift 4 solution:

       if let providerData = Auth.auth().currentUser?.providerData {
            for userInfo in providerData {
                switch userInfo.providerID {
                case "facebook.com":
                    print("user is signed in with facebook")
                case "google.com":
                    print("user is signed in with google")
                default:
                    print("user is signed in with \(userInfo.providerID)")
                }
            }
        }
    

提交回复
热议问题