1

In my app, I use NSURLSession to download data from a server. The download happens in two scenarios: 1. on app launch 2. if refresh button pushed

I noticed one issue with the following operation:

  1. Open my app
  2. Put iPhone into sleep mode
  3. Awake iPhone out of sleep mode
  4. Push refresh button
  5. ERROR - I get "no connection error"
  6. Push refresh button again - download starts with success

It seems like my app doesn't have an internet connection active each time iPhone awakes from sleep mode. But it restores connection when I push refresh for the second time.

  • when you call api... first check internet connectivity... this will restore internet connection before calling any api – Divyanshu Sharma Mar 21 '16 at 11:03
  • @DivyanshuSharma Could you please provide any links on how to check connectivity? I think there should be an approach other than calling my api twice: first to get an error but restore connection and second to download data. I found one advise with reachability class http://stackoverflow.com/questions/30743408/check-for-internet-connection-in-swift-2-ios-9 Didn't test it yet, but some people told that it does not work with 3G connection – Dmitrii Molev Mar 21 '16 at 11:22

0 Answers0