Reputation: 193
I have an app that uses location services. It will send location data to the server when the app is in the foreground as well as when it's in the background.
Could the system possibly force my app to terminate due to heavy use of location services? Or is the "gap" in location data that my testers are noticing due to a poor GPS/internet signal?
Upvotes: 1
Views: 127
Reputation: 5029
According to the App Programming Guide for iOS:
In the App Termination section (emphasis added),
Apps must be prepared for termination to happen at any time and should not wait to save user data or perform other critical tasks. System-initiated termination is a normal part of an app’s life cycle. The system usually terminates apps so that it can reclaim memory and make room for other apps being launched by the user, but the system may also terminate apps that are misbehaving or not responding to events in a timely manner.
Apple does not define "misbehaving," but making very frequent network or GPS location requests while in the background state is simply not being a good citizen. You could decrease the frequency of those updates by subscribing to location changes with less accuracy. (The significant-change location service is highly recommended by Apple.)
Unless precise and continuous location data are crucial for your app (as may be the case for navigation apps, for example), you should try to limit your use of location services while in the background state.
From the Background Execution section of the same guide,
Apps that need to run in the background to support specific types of tasks can declare their support for one or more background execution modes.
So if you happen to need location updates with the best possible accuracy and you properly declare your support for that background mode, the system will likely be more tolerant of any frequent background task execution, resource hogging, or other "misbehavior." However, declaring support for a background mode does not exempt your app from attempting to minimize its resource usage footprint; you should still try your best to be a good citizen.
To answer your questions,
Upvotes: 1