使用后台模式进行位置更新时,在iOS中消耗过多的移动数据

时间:2017-02-13 10:21:43

标签: ios objective-c iphone swift cllocation

我使用位置更新在后台模式上连续点击服务器API。它运行良好,但每天都会收集过多的移动数据。有没有办法保存移动数据?

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
self.locationManager.pausesLocationUpdatesAutomatically = NO;
[self.locationManager requestAlwaysAuthorization];
[self.locationManager startMonitoringSignificantLocationChanges]; 

  if ([self.locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)])
  {
    [self.locationManager setAllowsBackgroundLocationUpdates:YES];
  }

  [self.locationManager startUpdatingLocation];

- (void) locationManager:(CLLocationManager *)manager 
         didUpdateLocations:(NSArray *)locations
{
    [self invokeAPIWithTimerToUpdateUserLocationOnServer];  
}

0 个答案:

没有答案