I have an app which does periodic location updates to map the users path.

I am using deferred updates.

```
if (CLLocationManager.deferredLocationUpdatesAvailable() == true && _isDeferingUpdates == false)
        {
            print("Doing refresh")
            _isDeferingUpdates = true
            _locationManager.allowDeferredLocationUpdatesUntilTraveled(C_GPS.ACTIVITY_UPDATE_DISTANCE, timeout: C_GPS.ACTIVITY_UPDATE_TIME)
        } else
        {
            print("Could not refresh")
            // iPhone 4S does not have deferring so must keep it always on
            _locationManager.startUpdatingLocation()
        }

```

When the app is open I get the "doing refresh" call every second.

My setup:

Have the 2 keys on my pList NSLocationWhenInUseUsageDescription && NSLocationAlwaysUsageDescription

Have background modes turned on, for Remote Notifcations and Location Updates.

Have Maps setup to use Bike and Pedestrian.

Have all the permissions on my phone set to yes.

Do you know any other reason why my deferred update is failing when my app goes to the background?

Its never working and apples documentation is less than helpful

> 
> DeferredFailed The location manager did not enter deferred mode for an
>  unknown reason. This error can occur if GPS is unavailable, not
>  active, or is temporarily interrupted. If you get this error on a
>  device that has GPS hardware, the solution is to try again.
> 
> 
> 

Here is my error handler:

```
func locationManager(manager: CLLocationManager, didFinishDeferredUpdatesWithError error: NSError?)
{
    print("FINISHED BACKGROUND UPDATE with error \(error)")
    if (error != nil)
    {
        print("ERROR IS VALID as CLError")

        if (error!.code == CLError.LocationUnknown.rawValue)
        {
            print("Error: Location Unknown")
        } else if (error!.code == CLError.DeferredAccuracyTooLow.rawValue)
        {
            print("Error: Accuracy too low")
        } else if (error!.code == CLError.DeferredFailed.rawValue)
        {
            print("Error: Deferring Failed")
        } else if (error!.code == CLError.Denied.rawValue)
        {
            print("Error: Denied")
        } else
        {
            print("Error not handled")
        }

    }
    _isDeferingUpdates = false
}

```