2

After iOS 3.2, Apple allowed us to keep running our application in background mode. Using the same concept, in my application I have downloading functionality implemented which runs over in background mode.

The problem is that whenever I force quit my app manually, (Double tap on home button > long tap on app icon > tap on cross button of app) as per Apple specifications. I am not able to track that event in code, hence I am unable to track my downloading data.

Because of that, my data is being lost. So how to track this and track/save data before it gets force quitted.

Reference: AppDelegate Protocol

Ben
  • 51,770
  • 36
  • 127
  • 149
Mrunal
  • 13,982
  • 6
  • 52
  • 96

2 Answers2

4

As far as I know, there is no way to handle that event, since it kills the whole process immediately.

You will need to save your data periodically or just leave it like it is. User killing apps, should be aware of that he is killing apps.

Tricertops
  • 8,492
  • 1
  • 39
  • 41
2

track each 'chunk of data' as you receive it and you write it to disk. that way you don't have to rely on a shutdown event


Thats how ASI and AFN do it and thats how you could also manually do it using NSURLConnection directly.

On startup, see if and how much of the data you already have in the file. Again ASI and AFN make this really easy!

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135