Firebase Android addListenerForSingleValueEvent sometimes not returning data

前端 未结 4 1706
灰色年华
灰色年华 2021-01-17 10:34

When my application starts, I check the current user\'s details in my Firebase database (I\'m storing it\'s uid for that).

I\'m attaching addListenerForSingleValueEv

4条回答
  •  迷失自我
    2021-01-17 10:55

    I've been having the same problem for days and I finally fixed it.

    Looks like my Api key was changed! And that's what was preventing addListenerForSingleValueEvent() from returning!
    Go to Firebase Console, open your project, click the settings icon and go to Project settings. There you'll see Web API Key. Take that and copy it to your google-services.json file in your project's directory. Here's a snippet from that file:

      ...
      ],
      "api_key": [
        {
          "current_key": ""
        }
      ],
      ...
    

    That's it. After replacing the value of "current_key" with the key from Firebase, it returned to work (previously it had some other key I think I generated at Google Console and it worked for months. Just a few days ago it stopped working)

提交回复
热议问题