title: CLError.DeferredFailed Error (kCLErrorDomain Code=11) Deferred GPS Updates Failing
body: <p>I have an app which does periodic location updates to map the users path.</p>
  
  <p>I am using deferred updates.</p>
  
  <pre><code>if (CLLocationManager.deferredLocationUpdatesAvailable() == true &amp;&amp; _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()
          }
  </code></pre>
  
  <p>When the app is open I get the "doing refresh" call every second.</p>
  
  <p>My setup:</p>
  
  <p>Have the 2 keys on my pList NSLocationWhenInUseUsageDescription &amp;&amp; NSLocationAlwaysUsageDescription</p>
  
  <p>Have background modes turned on, for Remote Notifcations and Location Updates.</p>
  
  <p>Have Maps setup to use Bike and Pedestrian.</p>
  
  <p>Have all the permissions on my phone set to yes.</p>
  
  <p>Do you know any other reason why my deferred update is failing when my app goes to the background?</p>
  
  <p>Its never working and apples documentation is less than helpful</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>Here is my error handler:</p>
  
  <pre><code>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
  }
  </code></pre>