0

I have an issue with NSURLSession. My iOS8 iPhone app relies on this class in order to fetch data from a server continuously (every 5 - 10 seconds). So I create a session object when I init a custom controller designed to interact with the server. This is what I do:

override init() { 
    super.init()

    var configuration = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(thisSessionIdentifier)
    session = NSURLSession(configuration: configuration, delegate:self, delegateQueue:NSOperationQueue.mainQueue())

    ...  
}

Everything was working fine until yesterday. Today the call to the NSURLSession simply blocks the app completely when I test it on a physical iPhone 6. This does not happen on the simulator.

Uninstalling the app and reinstalling it again (even with a different bundle id) doesn't solve the issue.

Anybody with some clue?

pacification
  • 5,838
  • 4
  • 29
  • 51
micamoita
  • 450
  • 2
  • 14
  • 1
    Not an answer to your question, but polling the server 6-12 times a minute is going to be a big drain on the device's battery. – Anorak Oct 09 '14 at 09:53
  • Thank you for your observation. Of course this is challenging for the battery, and it is even more challenging when you also have to send your location to the server, with the maximum accuracy available. However, this is not a problem in our specific environment. – micamoita Oct 09 '14 at 09:59

2 Answers2

0

I have had this happen to a couple of real users on iOS7. The only way out for them was to wipe and restore the device from backup.

Disappointing this is still a problem on iOS8.

Daniel Broad
  • 2,512
  • 18
  • 14
  • Thank you for sharing your experience. However, maybe restoring the device is not necessary. In my case - if I remember correctly - I solved it by uninstalling the app, rebooting the device, and then installing the app again. – micamoita Oct 30 '14 at 10:41
0

I ran into the same problem. I'm suspecting it's an iOS bug.

See: Why does connecting back to an iOS background NSURLSession take too long waiting on a lock, crashing the app?

Community
  • 1
  • 1
Rayyan
  • 71
  • 4