3
私はiPhoneアプリでジオロケーションを使用しています。ジオロケーションを数秒間使用した場合でも、アプリがバックグラウンドである場合でも、バッテリーはより早く消耗します。iOS:ジオロケーションがまだオンになっているかどうかを確認する方法
iPhoneデバイスでジオロケーションサービスがまだオンになっているかどうかを確認するにはどうすればよいですか?これは私が使用したコードです:
...
locationManager = [[CLLocationManager alloc] init]; // Create new instance of locMgr
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
NSLog(@"locationManager startUpdatingLocation");
reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:locationManager.location.coordinate];
reverseGeocoder.delegate = self;
[reverseGeocoder start];
}
...
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{
NSLog(@"reverseGeocoder failed: %@", [error localizedDescription]);
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
NSLog(@"locality %@", placemark.locality);
location = [placemark.locality retain];
}