[英]iOS 8 CLLocationManager enterRegion: not getting called if use requestWhenInUseAuthorization
I'm trying to get being called the delegate method locationManager:didEnterRegion in iOS 8 for custom region.我正在尝试在 iOS 8 中为自定义区域调用委托方法 locationManager:didEnterRegion。 Here is the code:这是代码:
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(20, 20) radius:1000 identifier:@"asda"];
region.notifyOnEntry = YES;
region.notifyOnExit = YES;
[self.locationManager startMonitoringForRegion:region];
It does call method locationManager:didStartMonitoringForRegion
, but it doesn't call "enter" or "exit" region methods.它确实调用了locationManager:didStartMonitoringForRegion
方法,但它不调用“进入”或“退出”区域方法。
The one more strange thing is that it DOES work if I use requestAlwaysAuthorization for locationManager.更奇怪的是,如果我对 locationManager 使用 requestAlwaysAuthorization,它确实可以工作。 But I need to get it worked with "When In Use".但我需要让它与“使用时”一起工作。
Note: In iOS7 it works for both WhenInUse and Always Authorization methods.注意:在 iOS7 中,它适用于 WhenInUse 和 Always Authorization 方法。
region monitoring - it's not working with requestWhenInUseAuthorization
区域监控 - 它不适用于requestWhenInUseAuthorization
check Apple Docs: " .. “when-in-use” ... Apps cannot use any services that automatically relaunch the app, such as region monitoring or the significant location change service
"检查 Apple Docs:“ .. “when-in-use” ... Apps cannot use any services that automatically relaunch the app, such as region monitoring or the significant location change service
“
You must call requestAlwaysAuthorization
!!!您必须调用requestAlwaysAuthorization
!!! https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestWhenInUseAuthorization https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestWhenInUseAuthorization
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.