最初,我在检查问题时发现问题,看看我们是否已将数据保存到钥匙串中。我发现这个职位,并随后BhavinBhadani建议:GIDSignIn.sharedInstance()。currentUser当重新启动应用程序时为零
Whenever you check if ([GIDSignIn sharedInstance].hasAuthInKeychain) , before that add your sign in scopes..
https://github.com/googlesamples/google-services/issues/27
这解决了我的第一个问题的GIDSignIn.sharedInstance().hasAuthInKeychain()
返回true的用户成功登录之前后再已造成应用程序并重新运行。即使这样做后
let signIn = GIDSignIn.sharedInstance()
signIn.scopes = [Constants.GOOGLE_CLIENT_SCOPE, Constants.GOOGLE_OIDC_SCOPE]
if GIDSignIn.sharedInstance().hasAuthInKeychain() {
print("We have saved in keychain")
if let u = GIDSignIn.sharedInstance().currentUser {
getData(dataApi)
}
else {
// THIS CODE IS BEING SUCCESSFULLY HIT
GIDSignIn.sharedInstance().signInSilently()
getApplicationData(dataApi)
}
}
但是:
但是我现在做以下GIDSignIn.sharedInstance().signInSilently()
的GIDSignIn.sharedInstance().currentUser
为零。
是否有人成功使用signInSilently()
来再次填充当前用户数据?
这不是很快 –
我已经编辑了答案,以包含帖子中的代码。问题中提到的问题是关于当前用户为零。我还写道:'这已经解决了我的第一个GIDSignIn.sharedInstance()问题。hasAuthInKeychain()在用户成功登录之后返回true,然后杀死了应用并重新运行。'。我还问:'有没有人成功使用过signInSilently()来再次填充当前用户数据?' – pls
@pls是否会在崩溃时提供任何日志? –