问题
I try to use GoogleSignIn in my project, but I have problem when call GIDSignIn.sharedInstance().signIn()
I received warning below:
[Warning] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<SFAuthenticationViewController: 0x7fccba008c00>)
And in "GIDSignInDelegate", always had error "The user canceled the sign-in flow."
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {}
I searched on somewhere but could not got any solutions for this case, thanks for reading, I hope you will help me :((
UPDATE 1: add GIDSignInUIDelegate implementation
extension MyClass: GIDSignInUIDelegate {
func sign(inWillDispatch signIn: GIDSignIn!, error: Error!) {
print(#function)
}
func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) {
print(#function)
self.present(viewController, animated: true, completion: nil)
}
func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!) {
print(#function)
self.dismiss(animated: true, completion: nil)
}
}
and I received message below:
[Warning] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<SFAuthenticationViewController: 0x103023800>)
UPDATE 2: Some time alert (in image blow) is shown, then I tap on cancel and it can not shown again Image here
回答1:
if you use GIDSignInButton, replace it with the system's UIButton. It works for me.
回答2:
I also had the same issue. The GIDSignInButton object don't need addTarget in code or linking @IBAction. The GIDSignInButton class already handled that action for us.
来源:https://stackoverflow.com/questions/50140279/googlesignin-always-return-the-user-canceled-the-sign-in-flow-in-ios-11