Considering the impact on battery, I would like to let users decide if the functionality of my app is something they want all the time as in "multitasking/background execution" or just when the app is in the foreground. Reading this thread:
How do I get a background location update every n minutes in my iOS application?
gave me some ideas about what might be the best way to provide a user option to enable the multitasking function. I am hoping someone who has considered this dilemma may have a suggestion on the "best way" to go about it.
Problem - Location multitasking is enabled via the plist by setting the UIBackgroundModes item to 'location'. This is app-wide and permanent. How to make the function correspond to a NSUserDefault?
Potential Solution A - My proposal goes something like this:
- (void)applicationWillResignActive:(UIApplication *)application {
if ( [[NSUserDefaults standardUserDefaults] boolForKey:@"wantsBackgroundLocationEventProcessing"] ) {
//Continue using the location subsystem
} else {
self.locationManager = nil; //Custom setter does all required cleanup
}
}
However, my fear is that in this case the app will still receive location events, it simply won't be able to actually do anything with them - the effect on battery life will still be present.
Any ideas on how to make UIBackgroundModes 'location' optional during runtime?