IOS中的区域监控问题

我正在开发4-5个月的地区监测,之前工作正常。 在一个星期前,当我们testingIOS 7.1设备上的代码时,我们发现了一个问题:

  • 当检测到一个注册区域时,直到用户远离该区域移动10Km,否则永远不会再被检测到。如果用户永远不会跨过这个10Km的范围,那么将不会调用该区域的Enter / Exit事件。 如果用户远距离探测区域行进10公里,则会调用其Exit事件,当用户返回到注册区域附近时,Enter事件将仅被触发。

这是我的代码: – 我做了一个位置pipe理器的单身,并在位置pipe理器中初始化它:

if (locationManager == nil) { locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.desiredAccuracy = kCLLocationAccuracyKilometer; if ([locationManager respondsToSelector:@selector(activityType)]) { [locationManager setActivityType:CLActivityTypeFitness]; } if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { [locationManager requestAlwaysAuthorization]; } } 
  • 然后,我得到用户的当前位置,并将其发送到服务器,以获取附近的geofence区域,并注册他们进行监控如下:

     - (void)startRegionMonitoring:(NSArray*)regions { [self unregisterRegionMonitoring]; if ([Helper isValidForRegionMonitoring]) { [locationManager setDelegate:self]; int MAX_REGION = regions.count > 20 ? 20 : regions.count; for (int index=0; index<MAX_REGION; index++) { NSString *identifier = [NSString stringWithFormat:@"Identfier %d", index+1]; CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake([[[regions objectAtIndex:index] valueForKey:@"lat"] doubleValue], [[[regions objectAtIndex:index] valueForKey:@"lon"] doubleValue]); CLRegion *region = nil; double radius = 200.0; if ([Helper isIOS7]) { region = [[[CLCircularRegion alloc] initWithCenter:centerCoordinate radius:radius identifier:identifier] autorelease]; } else { region = [[[CLRegion alloc] initCircularRegionWithCenter:centerCoordinate radius:radius identifier:identifier] autorelease]; } [locationManager startMonitoringForRegion:region]; } } } 

我尝试了不同的“distanceFilter”,“DesiredAccuracy”的值,并用不同的值来监测区域的半径来修复bug。 但它没有工作。