iOS GPS定位跟踪

iOS GPS定位跟踪,ios,objective-c,gps,Ios,Objective C,Gps,我在Xcode上用Objective C编程,当我的应用程序进入后台时,似乎遇到了问题。我有一个GPS跟踪应用程序,当用户运行该应用程序时,它可以正常工作,但当它进入后台时,GPS不会一步一步地跟踪用户的位置。它会暂停,然后当应用程序重新打开时,它会自动找到位置,但我希望GPS一直在运行,这样它就不会像附件中的图片那样“偏离道路” 我已经在后台模式下打开了位置更新和后台提取 #pragma mark - CLLocationManagerDelegate - (void)locat

我在Xcode上用Objective C编程,当我的应用程序进入后台时,似乎遇到了问题。我有一个GPS跟踪应用程序,当用户运行该应用程序时,它可以正常工作,但当它进入后台时,GPS不会一步一步地跟踪用户的位置。它会暂停,然后当应用程序重新打开时,它会自动找到位置,但我希望GPS一直在运行,这样它就不会像附件中的图片那样“偏离道路”

我已经在后台模式下打开了位置更新和后台提取

   #pragma mark - CLLocationManagerDelegate
   - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:          (NSArray *)locations
   {

if (!self.timerPause) {
    for (CLLocation *newLocation in locations) {

        NSDate *eventDate = newLocation.timestamp;

        NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];

        if (fabs(howRecent) < 10.0 && newLocation.horizontalAccuracy < 20) 

将此添加到已设置位置管理器的位置。它应该可以工作:)

您的
CLLocationManager有哪些设置?特别是活动类型?您正在使用延迟的位置更新吗?您是否已将
allowsBackgroundLocationUpdates
设置为true?您正在处理
didUpdateLocations
中的所有位置吗?您是否已将活动类型设置为
CLActivityTypeAutomotiveNavigation
?@Paulw11如果您可以看一看,我用我的代码更新了我的帖子。为什么要丢弃超过10秒的位置?位置更新延迟并不意味着它不是一个应该记录的有效位置。请参阅链接:完成了任务!谢谢
     if (self.locationManager == nil) {
    self.locationManager = [[CLLocationManager alloc] init];
}
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.activityType = CLActivityTypeAutomotiveNavigation;
self.locationManager.distanceFilter = 10; // meters
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
    [self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
locationManager.allowsBackgroundLocationUpdates = YES;