Search code examples
iphoneiosipadcore-locationcllocationmanager

Programmatically change Required background modes


I have an app that need Location Based Services in the background. So in info.plist I setrRequired background modes to "App registers for location updates". and everything works fine.

My question is, how can I disable it running in background? Is it possible to add an option and let users set it on/off?

As I know info.plist can not be change programmatically so how can I do this?


Solution

  • The key is the description - it supports registering for location updates. So all you should have to do is tell your location manager to stop updating when the app goes into the background (or before) and it should then not be using location updates in the background.

    There is no way to re-define the info.plist abilities of the app at runtime.