ios - Google SignIn - 始终返回“用户取消了登录流程”
问题描述
我正在使用下面的代码片段通过 google 登录,但总是返回“用户取消了登录流程”
if GIDSignIn.sharedInstance.hasPreviousSignIn() {
logout()
}else {
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
let signInConfig = GIDConfiguration.init(clientID: clientID)
GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: getWindowTopController()) { user, error in
guard error == nil else { return }
guard let authentication = user?.authentication,let idToken = authentication.idToken else { return }
}
错误:错误 Domain=com.google.GIDSignIn Code=-5 “用户取消了登录流程。” UserInfo={NSLocalizedDescription=用户取消了登录流程。}
你能帮我解决这个问题吗?
解决方案
试试下面的代码
GIDSignInButton 对象不需要代码中的 addTarget 或链接@IBAction。GIDSignInButton 类已经为我们处理了该操作。
从这里得到它 如何在 iOS 上使用 Sign In with Google 修复“用户取消了登录流程。”?
如果上面的代码不起作用,请尝试下面的代码
推荐阅读
- windows - 如何在路径中转义百分比符号(批处理脚本)
- php - 从外部文件呈现 PHP 代码的另一种方法
- c# - c# || 我需要一个变量来控制另一个变量,但都计算自己的范围。我怎么能这样做?
- server - 工作几天后服务器上的Redis坏了
- python - 将 Silenium 与 Chrome 的 webdriver 一起使用并获得“权限被拒绝”或“没有这样的文件或目录”(Mac)
- python - 我得到 x 和 y 标签和增量数据,但没有图表线。使用 Jupyter 笔记本
- swift - SwiftUI contextMenu 显示以前的值
- javascript - Electron:添加 redux 开发工具
- javascript - 未捕获的类型错误:无法读取未定义 Javascript 的属性“长度”
- webpack - 启动本地开发服务器:这会打开计算机到互联网吗?