Application network reachability and resumption of streaming audio after phone call
I'm about to submit my app. Its plays some radio streams. And displays some info from my web server.
1)It does a check when the app starts for reachability and informs the user if there no connection available. Do i need to do more here, like keep popping up alerts if the user starts trying to play the radio even if there is no connection? Or checking once when the app starts enough? Maybe I would be expected to check on every button thats pressed that tries to play a radio station or that tries to download some data from the w开发者_StackOverflow社区eb server? Incase there is web connectivity when the apps starts but its later lost?
2) The app can play the radio streams in the background. Is there anything special related to this that I am expected to handle. If the app is interrupted by a phone call am I expected to make the radio resume automatically after the call or is it ok to leave that up to the user? The volume control on the side of the phone is ok to control the volume. I haven't hooked any other buttons from the phone itself to the app. Is this ok?
3) If there is anything else you think I should look into handling please feel free to suggest it.
Many Thanks -Code
The strategy I've generally taken, and which Apple have accepted, is to not do anything about reachability until the first time a communications attempt fails (a 'lazy' approach). Then I check for reachability:
a) if there is no internet connection available, I pop up a UIAlert saying something very much like, "There is no internet connection available. This application will have limited functionality until an internet connection is available." Thereafter, for each new comms error during that lack of internet connectivity, I just reflect the failure in the UI with "refresh failed", rather than showing the UIAlert again. Once the internet connection comes back, the UIAlert I described can be shown again should the connection fail again.
b) if an internet connection is available, and it's just that something went wrong with last comms attempt, I reflect the error in the UI somewhere (and not as a UIAlert -- they should be used sparingly)
As for your question 2., I think it's best to take Apple's example as the standard, unless there's good reason not to. iTunes resumes playing after you've taken a phone call, so it might be good to follow Apple's lead on that one. I would probably be annoyed as a user if I had to go back to the app to manually start the radio again after a phone call!
Have you set up the UIRequiresPersistentWifi
key in your application plist btw? Sounds like you want this enabled. It means that if you lose internet connectivity in a wi-fi only scenario, the app will prompt the user to join a wifi network that comes into range. See also: My iPhone app needs a persistent network connection...how to specify UIRequiredDeviceCapabilities?
One final thing: at the top of my answer I mentioned 'lazy' reachability test. However, if the first thing the user sees is a login screen, you might want to check for reachability proactively, because having the user type in a username and password only to then find out there is no internet connection makes for a poor user experience. It might be better if the app saves them the bother of typing, in that case.
精彩评论