iPhone屏幕关闭时,区域监控不会触发

时间:2014-06-17 02:27:26

标签: ios ios7 core-location geofencing region-monitoring

我正在使用带有IOS 7.1的iPhone5s进行测试。 我使用locationManagerDidPauseLocationUpdates委托来调用一个方法来设置地理围栏。

- (void) monitorForDepartureFromLastKnownStoppedLocation:(Locations *)lastKnownLocation
{

    CLLocationCoordinate2D lastLocation = CLLocationCoordinate2DMake(lastKnownLocation.latitude, lastKnownLocation.longitude);
    CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:lastLocation
                                                                 radius:300          
                                                             identifier:@"departure from last stopped location"]; 
    region.notifyOnEntry = NO;
    region.notifyOnExit = YES;        

    [monitorSignificantChangeObject.locationManager startMonitoringForRegion:region];       
}

然后,当用户退出该区域时,会调用- (void) locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region委托方法。

一切都适用于以下场景。

  • app in foreground。
  • app in background。
  • 使用背景或前景中的应用程序锁定屏幕。

在以下情况下,它无法正常工作:

地理围栏已经退出(即,didExitregion应该触发)并且屏幕被锁定并且屏幕关闭(即屏幕是黑色的,这在屏幕锁定后几秒钟发生)在这种情况下,didExitRegion不会触发所有。然而,只要我按下主页按钮,屏幕就会亮起(仍然锁定),didexitRegion会立即触发。

这是正常的行为,还是我错过了什么?

0 个答案:

没有答案
相关问题