沒有代碼示例是很難說最近出了問題我已經實現了谷歌登錄自己,但我用我自己的自定義按鈕,下面是我的代碼:
class SignInVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.clientID
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().delegate = self
}
@IBAction func googleSignInButton(_ sender: UIButton) {
GIDSignIn.sharedInstance().signIn()
}
extension SignInVC: GIDSignInDelegate, GIDSignInUIDelegate {
// [START headless_google_auth]
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
if let error = error {
print("README: Error when sign in with Google")
return
}
let authentication = user.authentication
let credential = FIRGoogleAuthProvider.credential(withIDToken: (authentication?.idToken)!, accessToken: (authentication?.accessToken)!)
//this method will finish login to Firebase
FirebaseLogin.sharedInstance.firebaseAuthentication(credential)
}