title: My iOS application does not update the location in background
body: <p>I have an iOS application developed in Swift. My app is currently in Swift 2 but I am using Xcode 8 with Swift 3. The app is configured to use the legacy swift language version.</p>
  
  <p>Until recently the app was working correctly.</p>
  
  <p>The app asks for the correct rights for always use the location and the autorisation is correctly set to always.</p>
  
  <p>I renewed the signing identity for the production app and the app stopped to be notified on a location update but was still working in development mode (launched from xcode).</p>
  
  <p>Now I revoked and renew the production and development certificate and the app does not update the location while in background whereas the autorisation is set to always.</p>
  
  <p>The app is correctly installed so I guess that the certificates are okay but I don't understand why the location is not updated in background.</p>
  
  <p>I run the app on an iPhone 7 with IOS 10.2 and xcode automatically manage signing.</p>
  
  <p>Here is my location manager configuration:</p>
  
  <pre><code>public class LocationManager : NSObject, ModuleManager, CLLocationManagerDelegate {
  
      /// The core location manager
      let coreLocationManager: CLLocationManager
  
      public var datas: JSONable? {
          get {
              return LocationDatas(locations: self.locations)
          }
  
          set {
              self.locations = newValue == nil ? [Location]() : newValue as? [Location]
          }
      }
  
      /// The list of locations to send
      private var locations: [Location]?
  
      /// The last location
      public var lastLocation: Location? {
          return self.locations?.last
      }
  
      public override init() {
  
          self.coreLocationManager = CLLocationManager()
          if #available(iOS 9.0, *) {
              self.coreLocationManager.allowsBackgroundLocationUpdates = true
          }
          // The accuracy of the location data.
          self.coreLocationManager.desiredAccuracy = kCLLocationAccuracyBest;
          // The minimum distance (measured in meters) a device must move horizontally before an update event is generated.
          self.coreLocationManager.distanceFilter = 500; // meters
          self.locations = [Location]()
  
          super.init()
          self.coreLocationManager.delegate = self
          self.locationManager(self.coreLocationManager, didChangeAuthorizationStatus: CLLocationManager.authorizationStatus())
  
      }
  
      // MARK: - CLLocationManager Delegate
  
      public func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
          NSLog("location update")
          guard locations.count &gt; 0 else {
              NSLog("Module Location -- no location available")
              return
          }
  
          // Add all location waiting in the list to send
          self.locations?.appendContentsOf(locations.map { Location(cllocation: $0) })
          SDKManager.manager?.sendHeartbeat()
      }
  
      public func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
          switch CLLocationManager.authorizationStatus() {
              case .NotDetermined:
                  if #available(iOS 8.0, *) {
                      self.coreLocationManager.requestAlwaysAuthorization()
                  } else {
                      self.coreLocationManager.startUpdatingLocation()
                  }
  
              case .Denied, .Restricted:
                  NSLog("Module Location -- access denied to use the location")
  
              case .AuthorizedAlways:
                  NSLog("AuthorizedAlways")
                  self.coreLocationManager.startUpdatingLocation()
                  //self.coreLocationManager.startMonitoringSignificantLocationChanges()
  
              default:
                  break
          }
      }
  
      public func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
          NSLog("Module Location -- error : \(error)")
      }
  }
  </code></pre>
  
  <p>The <code>locationManager</code> function is not called in background.</p>
  
  <p>Here is my info.plist:</p>
  
  <p><a href="https://i.stack.imgur.com/nckmc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nckmc.png" alt="enter image description here"></a></p>
  
  <p>Here is the authorization on the phone:</p>
  
  <p><a href="https://i.stack.imgur.com/FXocI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FXocI.jpg" alt="enter image description here"></a></p>
  
  <p>The little location arrow is always there but no location update is logged.</p>