Firebase:如何检查用户是否已登录? [英] Firebase: how to check if user is logged in?

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

问题描述

Firebase的新蜂,我正在尝试Firebase身份验证,并尝试检查用户是否已登录.
代码:

A new bee to Firebase, I am trying out the Firebase Authentication and trying to check if user is logged-in.
code:

null != mAuth.getCurrentUser();

尽管我未登录,但我启用了匿名登录,但这会返回 true ,我认为这可能是问题所在,但是当我检查时 mAuth.getCurrentUser().isAnonymous()我正在获取 false .

And this returns true though I am not logged in but I have enabled annonymous login and I thought that could be the issue but when I check mAuth.getCurrentUser().isAnonymous() I am getting false.

在IDE上检查 mAuth.getCurrentUser()会显示以下内容:

Inspecting mAuth.getCurrentUser() on the IDE shows this:

这里有什么方向吗?

推荐答案

我有一个类似的问题,那就是退出Firebase是不够的-它会再次自动登录.

I've had a similar issue and it was that signing out of Firebase is not enough - it will sign in automatically again.

还必须使用GoogleSignInApi退出:

It's necessary also to sign out using the GoogleSignInApi:

firebaseAuth.signOut();
Auth.GoogleSignInApi.signOut(apiClient);

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

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