私は現在、ロケーション マネージャーのリージョン機能に取り組んでいます。残念ながら、100m 未満の国境通過の通知を受け取ることができません。半径 20m / 50m または 70m のリージョンを作成しましたが、常に 100m の境界を越えるとすぐに通知が届きます。しかし、半径を細かくしたいと思います-たとえば20mで、その通知も受け取ります。範囲が 100m を超える場合 (例: 150m)、すべてがうまく機能します。この場合、予想どおり 150m に入るとすぐに通知を受け取ります。
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];
}
より近い境界で通知を受け取る方法を知っている人はいますか? どんな助けでも高く評価されます。
ありがとうハムト