Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long-Running Upload Task In Background

I am developing an app for iPhone that collects lots of data from vehicles and then uploads it to a remote server. The app itself will be sitting in the vehicle, connected to its battery for power, and collecting data without much user interaction for most of its life. Given that, it is important that these uploads be happening in the background and that the app be "woken up" be the system to do the upload. Also, this is an enterprise app, so the app will NOT need to be put through Apple's approval.

Given these requirements, I had thought that Apple's new iOS 7 background fetch API would be a good solution for my problem. Of course, since I'm not using it entirely as intended, there are some things that could cause some issues for me that I wanted some clarification on.

  1. After watching the WWDC video on the new API, I understand that iOS will attempt to recognize the app's usage patterns and have it woken up only right before it's used. If the app is rarely opened, will that cause it to, eventually, stop doing these background updates?

  2. When I do use this API, the completion handler block I'm given takes a UIBackgroundFetchResult as an argument. If I pass in UIBackgroundFetchResultFailed each time, would that cause iOS to think that I still need that new data and keep waking the app up?

  3. Lastly, since I'm clearly using this API in a different way than it was intended, could someone recommend a better way to do this that would still meet my requirements?

like image 303
Zachary Gay Avatar asked Dec 13 '13 21:12

Zachary Gay


1 Answers

With this given: "app itself will be sitting in the vehicle, connected to its battery for power, and collecting data without much user interaction for most of its life" and "Also, this is an enterprise app, so the app will NOT need to be put through Apple's approval.", why bother with background fetch API at all?

Pick a background mode such as VOIP, and run your task in background mode. Your network connection will stay alive and carrying out any sending/receiving even if screen was locked.

like image 72
user523234 Avatar answered Oct 22 '22 12:10

user523234