GoogleSignIn - 始终返回“用户取消了登录流程”。在 IOS 11

bao*_*g02 4 xcode swift google-signin ios11

我尝试在我的项目中使用 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>)
Run Code Online (Sandbox Code Playgroud)

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

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {}
Run Code Online (Sandbox Code Playgroud)

我在某处搜索过,但找不到任何解决方案,感谢阅读,希望你能帮助我:((

更新 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)
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下消息:

[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>)
Run Code Online (Sandbox Code Playgroud)

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

Tim*_*hyi 5

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