且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么FirebaseAuth.getInstance().getCurrentUser()在Android中返回空值

更新时间:2023-12-02 12:45:52

您的代码似乎离正式的 firebase文档

Your code seems to be far from oficial firebase documentation

  1. 确保您在Firebase控制台中启用了匿名登录
  2. 使用回调mAuth.signInAnonymously().addOnCompleteListener
  3. 匿名登录 在onComplete()中的
  4. 观察Task.isSuccessful()是否为真,如果不是,则返回task.getException().
  5. 并始终遵循官方文档,而不仅仅是您在github上找到的人
  1. ensure you have anonymous login enabled in firebase console
  2. sign in anonymously with callback mAuth.signInAnonymously().addOnCompleteListener
  3. in onComplete() observe whether Task.isSuccessful() is true and if not what task.getException() return.
  4. and always follow official documentation not just somebody you have found on github

如果您真的想知道为什么FirebaseUsernull的原因,请阅读

If you really want to know why your FirebaseUser is null, then read firebase docs

如果您发布例外情况,我可以为您提供帮助.

If you post the exception I can help you.