我开发的应用程序在进入和退出地理围栏时提醒用户。但是当我使用它而没有移动数据或wifi时,它不是非常准确且不快。所以我想每隔几秒钟使用计时器更新位置管理器。这对准确的地理围栏有帮助吗?
注意(替代方式):我试过没有使用地理围栏。具体位置和我与位置经理的当前位置,并获得距离。它比地理围栏更准确。但问题是当应用程序被杀时它无法正常工作。
CLLocationManager* locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
CLLocation *myLocation = [locationManager location];
float longitude=myLocation.coordinate.longitude;
float latitude=myLocation.coordinate.latitude;
CLLocation *officeLocation = [[CLLocation alloc] initWithLatitude:[location.latitude floatValue] longitude:[location.longitude floatValue]];
CLLocation *NewLocation = [[CLLocation alloc]initWithLatitude:latitude longitude:longitude];
CLLocationDistance distance = [officeLocation distanceFromLocation:NewLocation];
[locationManager stopUpdatingLocation];