谷歌登录按钮按检测ios
问题描述:
我在他们的登录按钮上的谷歌文档挣扎。基本上,我想在按下谷歌登录按钮后立即在屏幕上添加一个活动指示器。然而,只有两个是真的会从文档下文称为谷歌登录按钮按检测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")
}
答
问题解决了。通过像上面那样编程式地创建按钮,我无法解决它。我所做的就是创建一个UIButton和根本就以下
@IBAction func signInWithGoogleBtn(sender: AnyObject) {
activityIndicatorBegin()
GIDSignIn.sharedInstance().signIn()
}
发布您的代码... –
不知道IOS多,但一定要检查该“指南”:https://developers.google .com /身份/登录/ ios /开始 - 整合和这一个:https://developers.google.com/identity/sign-in/ios/sign-in –
代码张贴上尉。我确实通过了开发人员指导,这里是我卡住的地方。干杯 – user172902