我在他們的登錄按鈕上的谷歌文檔掙扎。基本上,我想在按下谷歌登錄按鈕後立即在屏幕上添加一個活動指示器。然而,只有兩個是真的會從文檔下文稱爲谷歌登錄按鈕按檢測ios
- signInWillDispatch:error:
功能登錄流程完成選擇如何進行,以及用戶界面應該不再顯示一個微調框或其他「請稍等」的元素。更多...
- signIn:didSignInForUser:withError:
的登錄流程已經完成,並已成功如果錯誤是零。更多...`
我不知道在哪裏我可以把我的beginActivityIndicator代碼,我不知道什麼函數被調用後,我立刻按谷歌登錄按鈕。
感謝,
代碼爲--update - 下面是我在我的loginVC從GIDSignInUIDelegate和GIDSignInDelegate繼承四大功能。幾乎我需要在SignInWillDispatch之前訪問函數,以便啓動活動指示器。但是,我無法找到它在文檔中的位置。我嘗試在Google按鈕上添加輕觸手勢識別器。當我這樣做時,登錄功能完全停止工作,就好像它只是一個空白UIView
// Google login buttob
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().delegate = self
// Uncomment to automatically sign in the user.
//GIDSignIn.sharedInstance().signInSilently()
// TODO(developer) Configure the sign-in button look/feel
let googleSignInBtn = GIDSignInButton()
googleSignInBtn.frame.size = loginButton.frame.size
googleSignInBtn.center.x = loginButton.center.x
googleSignInBtn.center.y = loginButton.center.y + 80
googleSignInBtn.style = .Wide
self.view.addSubview(googleSignInBtn)
func signIn(signIn: GIDSignIn!, presentViewController viewController: UIViewController!) {
print("Signed in with google")
}
func signInWillDispatch(signIn: GIDSignIn!, error: NSError!) {
print("Signin Will Dispatch")
}
func signIn(signIn: GIDSignIn!, dismissViewController viewController: UIViewController!) {
print("GoogleSignInDismiss")
}
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
activityIndicatorBegin() // Having the activity indicator start here is too late. I need it to start as soon as the google button is pressed. Otherwise there would be a moment just after the google view dismisses without activity indicator
if let error = error {
print(error.localizedDescription)
return
}
let authentication = user.authentication
let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication.idToken, accessToken: authentication.accessToken)
FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
if let error = error {
self.showErrorAlert("Error Sign in Firebase with google", message: error.localizedDescription)
} else {
}
self.activityIndicatorEnd()
}
}
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!, withError error: NSError!) {
// Perform any operations when the user disconnects from app here.
print("didDisconnectWithUser")
}
發佈您的代碼... –
不知道IOS多,但一定要檢查該「指南」:https://developers.google .com /身份/登錄/ ios /開始 - 整合和這一個:https://developers.google.com/identity/sign-in/ios/sign-in –
代碼張貼上尉。我確實通過了開發人員指導,這裏是我卡住的地方。乾杯 – user172902