如何检查用户是否具有有效的Auth Session Firebase iOS? [英] How to check if user has valid Auth Session Firebase iOS?

查看:78
本文介绍了如何检查用户是否具有有效的Auth Session Firebase iOS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在展示应用程序的Home View控制器之前,我想检查用户是否仍然具有有效的会话.我使用最新的Firebase API.我想如果我使用旧版软件,我就能知道这一点.

I wanna check if the user has still a valid session, before I present the Home View controller of my app. I use the latest Firebase API. I think if I use the legacy, I'll be able to know this.

这是我到目前为止所做的:

Here's what I did so far:

我尝试阅读iOS版Firebase的文档,但似乎无法理解: https://firebase.google.com/docs/reference/ios/firebaseauth/interface_f_i_r_auth

I tried reading the docs of Firebase for iOS, but I can't seem to comprehend it: https://firebase.google.com/docs/reference/ios/firebaseauth/interface_f_i_r_auth

我尝试这样输入Xcode:

I tried typing in Xcode like this:

FIRApp().currentUser()
FIRUser().getCurrentUser()

但是我似乎找不到该getCurrentUser函数.

But I can't seem to find that getCurrentUser function.

推荐答案

if FIRAuth.auth().currentUser != nil {
   presentHome()
} else {
   //User Not logged in
}

对于更新的SDK

if Auth.auth().currentUser != nil {

}

这篇关于如何检查用户是否具有有效的Auth Session Firebase iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆