I am looking for suggestions on the best way to solve network connectivity problems for an iPhone application (iOS9 / Swift2 / Xcode7) in order to provide a better user interface, since we know that mobile data networks are unreliable. I have my own encoding options, but I would like to know what works well for other experienced technicians. There is a lot of information, but I could not find anything in the strategy that occurs when the connection fails.
Here is my main strategy related to failed connections that I would like to implement (along with questions):
- The application sends a request to api.myserver.com and the request does not work
- Wait X seconds and try again to request api.myserver.com (how many attempts and for what time interval would you suggest?)
- Try pinging another server (e.g. google.com) to see if we can access a resource other than api.myserver.com
- If we can successfully ping google.com, then we know that our internet is working, so we will try ping api.myserver.com again
- If this last ping fails, we warn the user that for some reason we cannot contact, and try again later.
I use the philosophy set out in this SO tech - recommended SO tech answer , which generally means that you always check the connection to your server first and foremost, using Reachability as a separate test to ensure the phone’s hardware is available.
, Reachability , , .
, , , , " , , ... Apple ...". / ( ), , ?