首页 > 解决方案 > GoogleSignIn - 始终返回“用户取消了登录流程”。在IOS 11

问题描述

我尝试在我的项目中使用 GoogleSignIn,但调用时出现问题GIDSignIn.sharedInstance().signIn()

我收到以下警告:

[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>)

而在“GIDSignInDelegate”中,总是出现错误“用户取消了登录流程”。

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {}

我在某个地方搜索但找不到任何解决方案,感谢您的阅读,希望您能帮助我:((

更新 1:添加 GIDSignInUIDelegate 实现

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)
    }
}

我收到以下消息:

[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>)

更新 2:显示了一些时间警报(在图像中),然后我点击取消,它不能再次显示在这里图像

标签: swiftxcodeios11google-signin

解决方案


如果您使用GIDSignInButton,请将其替换为系统的UIButton. 这个对我有用。


推荐阅读