I am using coreLocation with an app that is registered for location updates in the background. Can I make network calls to a web service to download and store data while the app is in the background? I am having problems determining how much I can do in the background.
As an example, when the user makes a significant change to his/her location, could I make a call to a weather service requesting and logging the weather for that location (That’s not exactly what I’ll be doing but as an example of a web service)? Resulting in a list of places he/she has been and what the weather was at the time.
Can I make Network connections and requests while in the background to download data? Or am I limited somehow?? Or am I just limited by the amount of time my process takes.
I do understand the pitfalls of battery and network charges if an app is continually doing this. That for now is beside the point. Just looking for specifics on downloading data while the app is in the background.
Thanks in advance –
Your app is not necessarily running in the background just because you registered for the location service in the background. It is essentially woken up to process your delegate calls when your location manager sends a location event. If your location doesn’t change for some time, the app will be suspended and may even be terminated. The location manager, will wake it up and you will have a limited time to do work when a new location event is processed.
If you initiate a call for refresh data, wrapped in beginBackgroundTaskIdentifier and endBackgroundTaskIdentifier calls, you should get a decent chance to process the network data method. I don’t think that you can start that process or count on it being processed at any other time while in the background and possibly suspended.
The link that psoft references will give you a better idea on how to manage the process while in the background.