GoogleSignIn - Always return “The user canceled the sign-in flow.” in IOS 11

不打扰是莪最后的温柔 提交于 2020-01-04 09:22:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!