Firebase:如何检查用户是否登录? [英] Firebase: how to check if user is logged in?
问题描述
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屋!