title: How to track user location in background?
body: <p>I'm looking for an open source app or library to track user location in the background. Now I'm trying to do it with <code>CLLocation</code> and background tasks, but accuracy is not enough for my case. Could you explain, how apps, like "moves", "runkeeper", "endmondo", creates my route? Should I use Accelerometer or/and compass to create a route between CLLocation background points?</p>
  
  <p>Some code:</p>
  
  <pre><code>//location manager init
  self.locationManager = [[CLLocationManager alloc] init];
  self.locationManager.distanceFilter = kCLDistanceFilterNone;
  self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
  self.locationManager.delegate = self;
  
  
  #pragma mark - CLLocationManager Delegate
  
  - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
  
      if ([self isInBackground]) {
          if (self.locationUpdatedInBackground) {
              bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler: ^{
                  [[UIApplication sharedApplication] endBackgroundTask:bgTask];
              }];
  
              self.locationUpdatedInBackground(newLocation);
              [self endBackgroundTask];
          }
      } else {
          if (self.locationUpdatedInForeground) {
              self.locationUpdatedInForeground(newLocation);
          }
      }
  }
  </code></pre>
  
  <p>UPD:
  Justed tested my app with next properties</p>
  
  <pre><code>self.locationManager.distanceFilter = kCLDistanceFilterNone;
  self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
  self.locationManager.activityType = CLActivityTypeFitness;
  self.locationManager.pausesLocationUpdatesAutomatically=NO;
  </code></pre>
  
  <p>In this case I have about 10 fired events during 1,5 hour trip</p>