ios - 应用程序启动时 GIDSignIn.sharedInstance.currentUser 始终为零

标签 ios swift authentication gidsignin

我遇到了类似于 this one 的问题。基本上每次我的应用启动时,我都必须使用我的 Google 帐户登录。

然后,我有这个属性:

var isGoogleSessionOpen: Bool {
    return GIDSignIn.sharedInstance().currentUser != nil
}

应用程序开始检查是否必须显示 LoginViewController 时就会调用它。

我的问题是这个调用首先总是为零,所以我每次启动应用程序时都必须登录。

另外,正如上面提到的 here ,我正在这样配置范围:

if let signIn = GIDSignIn.sharedInstance() {
    signIn.scopes = ["https://www.googleapis.com/auth/plus.login","https://www.googleapis.com/auth/plus.me"]
}

请问有什么想法吗?

问候

最佳答案

应用程序启动时您需要登录。

GIDSignIn.sharedInstance().signInSilently()

关于ios - 应用程序启动时 GIDSignIn.sharedInstance.currentUser 始终为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52682431/

相关文章:

IOS 13 Combine Framework - @Published 不工作 ("Unknown attribute ' Published'")

php - CakePHP Auth 登录错误

ios - React Select 输入缩放——无法在 iPhone XS 上禁用

ios - 将 UIImages 数组转换为视频时出现黑框

ios - UIAlertAction 值列表

ios - 在 UIAlertController 的 UIAlertAction 中居中图像

ios - Apple 方法中隐式解包可选

swift - 如何使用 swift flatMap 从数组中过滤掉可选项

android - 如何实现在所有 Activity 中可用的登录 Activity 。安卓

具有细粒度访问控制的 Django 身份验证