我目前正在使用位置管理器的区域功能。 不幸的是,我无法收到任何小于100米的过境点的通知。 我创建了半径为20米/ 50米或70米的区域,一旦我越过100米边界,我总是只收到通知。 但我希望有一个更精细的半径 - 例如20米并且还收到通知。如果我有一个大于100米的范围,一切都很好 - 例如 150米。在这种情况下,一旦我按照预期进入150米,我就会收到通知。
我尝试使用LocationManager上的“kCLLocationAccuracy”设置和CLRegions的创建,但两者都没有 似乎有任何影响。
这是我使用的代码:
- (void) initializeLocationManager
{
// Check to ensure location services are enabled
if(![CLLocationManager locationServicesEnabled]) {
[self showAlertWithMessage:@"You need to enable location services to use this app."];
return;
}
if(![CLLocationManager regionMonitoringAvailable]) {
[self showAlertWithMessage:@"This app requires region monitoring features which are unavailable on this device."];
return;
}
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
}
- (void) setupGeoFence:(Station*)station
{
CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake([station.gpsPosition.latitude doubleValue], [station.gpsPosition.longitude doubleValue]);
CLRegion *geofence = [[CLRegion alloc] initCircularRegionWithCenter:centerCoordinate radius:[range doubleValue] identifier:station.name];
[self.locationManager startMonitoringForRegion:geofence desiredAccuracy:kCLLocationAccuracyBest];
}
有没有人知道如何在更近的边界接收通知?任何帮助都会受到高度关注。
由于 Hamtho
答案 0 :(得分:8)
那个大小的地区实际上是不可能的。位置事件主要由设备周围的Wifi触发。除非绝对必要,否则不会使用GPS。因此,50M以下的地区实际上是一个废话。我已经与CoreLocation工程师谈过这个问题(以及围绕区域监控的一些其他奇怪的行为),并且由于依赖于Wifi,不建议使用小尺寸。他们实际上推荐150M,即使没有记录。
如果您确实需要细粒度的位置更新,您可能需要实施自己的检查或启动GPS以获得非常准确的读数。这伴随着电池一击,因此您的里程可能会有所不同。祝你好运。