LocationManager Work on Backend in IOS

I'm developing a locaton tracking application using LocationManager on iPhone. The following is my questions. If users click Home button on iphone, which means the application is switched to backend, will the thread of location manager still work? Will the location manager update current location? The following is the sample code.

CLLocationManager *_locationManager;

- (void)startStandardUpdates {
    if (nil == locationManager) {
        locationManager = [[CLLocationManager alloc] init];

    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;

    // Set a movement threshold for new events.
    locationManager.distanceFilter = kCLLocationAccuracyNearestTenMeters;

        //Will the thread still work even the application is switched to background?
    [locationManager startUpdatingLocation]; 

    CLLocation *currentLocation = locationManager.location;
    if (currentLocation) {
        PAWAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
        appDelegate.currentLocation = currentLocation;


Maybe you should Log your location then.

There is also a very helpful tutorial about locationmanager in the background.

This might help you.

Only thing is, apple doesn't like this verry much and will probably kill your app after 20 minutes in background.


Good Luck,

If you have any questions, feel free to ask them.

The location manager, if you do not stop it or release it will continue until the app is suspended. If you set required background operations in info.plist, you can allow it to continue updating indefinitely. In that case, it wakes your app on events if your app is suspended.

That being said, calling methods in the background can be quite difficult.

There are a multitude of considerations if you are planning to use the service in the background state. Threading and locking, lack of UI and runloop idle issues abound. You should evaluate seriously what you are trying to accomplish and consider the simplest manner to achieve it. Battery life is number one issue for a portable device. Your feature must be of utmost benefit to the user to warrant the energy use. If you lock up the device or interfere with user actions, you will not be a welcome guest.

You can see my own handler example on github which can offer you some insight and solutions:


  • Notes from the Developer site

There are several ways to track the user’s location in the background, most of which do not actually require your app to run continuously in the background:

The significant-change location service (Recommended)

Foreground-only location services

Background location services

The significant-change location service is highly recommended for apps that do not need high-precision location data. With this service, location updates are generated only when the user’s location changes significantly; thus, it is ideal for social apps or apps that provide the user with noncritical, location-relevant information. If the app is suspended when an update occurs, the system wakes it up in the background to handle the update. If the app starts this service and is then terminated, the system relaunches the app automatically when a new location becomes available. This service is available in iOS 4 and later, and it is available only on devices that contain a cellular radio.

The foreground-only and background location services both use the standard location Core Location service to retrieve location data. The only difference is that the foreground-only location services stop delivering updates if the app is ever suspended, which is likely to happen if the app does not support other background services or tasks. Foreground-only location services are intended for apps that only need location data while they are in the foreground.

An app that provides continuous location updates to the user (even when in the background) can enable background location services by including the UIBackgroundModes key (with the location value) in its Info.plist file. The inclusion of this value in the UIBackgroundModes key does not preclude the system from suspending the app, but it does tell the system that it should wake up the app whenever there is new location data to deliver. Thus, this key effectively lets the app run in the background to process location updates whenever they occur.

enter link description here

Need Your Help

How to call Primefaces JavaScript function after pageload?

javascript jquery jsf primefaces wizard

I am using custom buttons for PrimefaceWizard and remove default navigation buttons from Primeface Wizard by adding the attribute showNavBar="false" .

SQL join - join first no zero element if possible


I have a data structure something like this: