Android Firebase onDataChange is not called?

前端 未结 2 1033
南旧
南旧 2020-12-11 22:37

I have more than 40,000 nodes in my Firebase Database. But whenever I am trying to read a key from my Android code, the onDataChange method is not getting calle

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-11 23:01

    First thing to do is to check you have correct permissions to read from your database. Go to https://console.firebase.google.com/project/[your_database_url]/database/rules and check . Not ideal in prod, but for testing you can set read to true

      {
      "rules": {
         ".read": true,
         ".write": "auth != null"
       }
      }
    

    Next gotcha is to remember that the listeners are asynchronous fire and forget calls. So any manipulations to the data should be done once the data has been received in the onDataChange() method.

提交回复
热议问题