I am working on an app that is expected to submit data to a remote server. The submit function does an Http Post and the response is handled accordingly.
My question is, what is the best way to handle network failures, offline mode, etc so that once a user has entered data, it is sent to the server, no matter what.
Couple of scenarios would be,
- User Online: Http post returns successful.
- User Online then lost connection: Http post made but returns error.
- User Offline: Save to local storage and try posting when network state changes to online.
- Server offline: Try posting data, fail, store back to local storage and try again in a background service.
How to best handle these cases?