The documentation says that After an error, the listener will not receive any more events, and there is no need to detach your listener.
But I don't want that behavior. Instead, I want the listener to be attached there itself, as in the future, there is still a chance of the listener getting permission to read from there.
Suppose if the rules say that, reading is allowed only if readField
is true
. Even if the current value of readField
is false
, it has a possibility of becoming true
, so I want the listener to keep listening till I manually remove it when there is no need.
CodePudding user response:
As the docs say, if your query fails or you have improper security rules, the listener will not receive any more events. Unfortunately, this behavior cannot be changed.
What you might try to implement, is to attach the listener again, if you get an error message. But this might not be the best solution because if you forget the add the proper rules, you'll end up adding the listener over and over again.
What you should do is attach and detach the listener according to your app state. For instance, in Android you do something like this: