Reputation: 147
My question is: Is CLLocationManager continue running, while my app is inactive?
Upvotes: 6
Views: 8053
Reputation: 979
There are some important subtleties with this (as of iOS 7.1):
Hope that helps!
Upvotes: 2
Reputation: 300
To disable CLLocationManager while the app is in backround mode you simply must not add the "App registers for location updates" in the "Required background modes" key of the info.plist file.
I suggest to use the significant-change location service instead of the standard location service whenever possible, to preserve device battery.
Upvotes: 1
Reputation: 13057
Yes, it could. You have two options for handling location service events when your app is suspended, which can be read at the article: Getting the User’s Current Location. As noted:
There are two different services you can use to get the user’s current location:
- The standard location service is a configurable, general-purpose solution and is supported in all versions of iOS.
- The significant-change location service offers a low-power location service for devices with cellular radios. This service is available only in iOS 4.0 and later and can also wake up an application that is suspended or not running.
Also, as noted at the bottom of this article in the section "Getting Location Events in the Background":
- If your application needs location updates delivered whether the application is in the foreground or background, there are multiple options for doing so. The preferred option is to use the significant location change service to wake your application at appropriate times to handle new events. However, if your application needs to use the standard location service, you can declare your application as needing background location services.
- An application should request background location services only if the absence of those services would impair its ability to operate. In addition, any application that requests background location services should use those services to provide a tangible benefit to the user. For example, a turn-by-turn navigation application would be a likely candidate for background location services because of its need to track the user’s position and report when it is time to make the next turn.
Upvotes: 2
Reputation: 15213
Yes, if CLLocationManager
is first called startUpdatingLocation
method, and in the AppName-Info.plist
file is added Required Background Modes -> App registers for location updates
Upvotes: 9