I have a weird situation, client does’t want their application to support multitasking so I created a flag in info.plist like,
Application does not run in background = YES;
However there are times during application lifecycle that the application must upload some data to server before it terminates. If it doesn’t then server will have fuzzy data and my client’s company (and probably me too…) will be doomed!!!
Now my questions are,
- How much time do I have before OS will terminate my app? Sometimes data can be large to upload and if internet is slow then I might need more time.
- I saw this method beginBackgroundTaskWithExpirationHandler will this work in my situation. I doubt as this might work if I do support background execution. am I right?
Final questions,
- Any other options I can think of?
- should I resign as a iOS developer?
Thanks
My advice would be to try something like this:
Just put that code in the
initmethod of your class. Be sure to remove yourself as an observer in viewDidUnload like this:Here you can save whatever you need to save, but I’m not sure about uploading data. Your best bet is to save the data to a file here, and then next time the app is opened upload the data from the file to the server asynchronously. You can try uploading it with this notification, I’m just not sure Springboard is going to wait around for that to happen.