简体   繁体   English

iOS 8 CLLocationManager enterRegion:如果使用 requestWhenInUseAuthorization,则不会被调用

[英]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.

相关问题 在iOS 8中未调用CLLocationmanager updateLocations委托方法 - CLLocationmanager updateLocations delegate method not getting called in iOS 8 使用Swift 2.0的iOS上的CLLocationManager requestWhenInUseAuthorization()在iOS7上不起作用 - CLLocationManager requestWhenInUseAuthorization() not working on ios7 using swift 2.0 CLLocationManager requestWhenInUseAuthorization()不起作用 - CLLocationManager requestWhenInUseAuthorization() not working iOS 4.1 CLLocationManager委托停止被调用-RunLoop是否被阻止? - iOS 4.1 CLLocationManager delegate stops getting called - RunLoop blocked? CLLocationManager没有定义requestAlwaysAuthorization或requestWhenInUseAuthorization - CLLocationManager does not define requestAlwaysAuthorization or requestWhenInUseAuthorization iOS:未调用 CLLocationManager 的 didEnterRegion - iOS: CLLocationManager's didEnterRegion not called CLLocationManager委托方法未被调用 - CLLocationManager Delegate methods are not getting called CLLocationManager requestWhenInUseAuthorization错误,没有已知的类方法 - CLLocationManager requestWhenInUseAuthorization errors with no known class method CLLocationManager didUpdateLocations没有通过plist条目被称为iOS 8 - CLLocationManager didUpdateLocations not being called iOS 8 with plist entries IOS 7.1上的requestWhenInUseAuthorization错误 - requestWhenInUseAuthorization error on IOS 7.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM