swift - 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:显示了一些时间警报(在图像中),然后我点击取消,它不能再次显示在这里图像
解决方案
如果您使用GIDSignInButton
,请将其替换为系统的UIButton
. 这个对我有用。
推荐阅读
- haskell - 是什么导致“Prelude.chr:不好的论点”?
- javascript - 为什么发件人不=收件人?
- angular - 为什么我的 Angular 10 http.post 订阅块代码没有被执行?
- c# - 强制字符串插值始终遵循 CultureInfo.InvariantCulture
- python - 将使用 C++ 和 Open MPI 生成的处理器等级发送到 Python 脚本
- azure-devops - 如何从 *.nuspec 在 Azure Pipelines 中仅设置主要和次要 NuGet 包版本?
- excel - Oracle12C 查询和 Access 查询有什么区别?
- amp-html - (十一) 如何为src *.md文件生成rel="amphtml" 格式
- javascript - 使用 javascript 查找活动的引导模式
- c++ - 如何使用 Mac 终端执行我的 C++ 程序?