Addonfailurelistener Not Working In Offline Mode And Network Issues
Solution 1:
It's not a failure to attempt to write data while offline. The Firestore SDK will write the data in a local offline cache first, and eventually synchronize that write with the server when the app comes back online. The success listener will be invoked whenever that happens.
Write failures only happen when there is some problem that can't be retried due to lack of connectivity, such as security rule violations, or exceeding some documented limit of the database.
If you want to know if some document data is not yet synchronized with the server, you can check its metadata to know if a write is pending.
Solution 2:
The get
functionality is working because the call could not take place, whereas in add
it must be getting completed that's why it is not showing in OnFailure
. Also read below.
publicabstract Task<TResult> addOnFailureListener(OnFailureListener listener)
Adds a listener that is called if the Task fails.
The listener will be called on main application thread. If the Task has already failed, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.
A canceled Task is not a failure Task. This listener will not trigger if the Task is canceled. For more information visit this link.
Post a Comment for "Addonfailurelistener Not Working In Offline Mode And Network Issues"