我目前正在使用位置管理器的region-feature。 不幸的是,我無法獲得任何小於100米的邊界通道的通知。 我創建了半徑爲20米/ 50米或70米的地區,只要我穿過100米邊界,我總是隻收到通知。 但我想有一個更好的半徑 - 例如20米,也收到通知。如果我有一個大於100米的距離,一切都很好,例如 150m。在這種情況下,只要我按照我的預期輸入150米就會收到通知。iOS的CLRegion功能的最小半徑LocatinManager
我試着在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];
}
有沒有人有一個想法如何得到一個更接近邊界的通知?任何幫助將高度appriciated。
感謝 Hamtho
150米的建議是否適用於iOS 5-7? – Pochi
是的。我通常推薦100M以獲得最佳效果,但100-150之間的任何值都可以使用。 –
謝謝,生病做了一些測試。 – Pochi