Last active
May 5, 2016 03:41
-
-
Save nfarah86/e95e50ced7c36750a6feaea6f1673add to your computer and use it in GitHub Desktop.
Set Location Details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
- (void)startStandardUpdates{ | |
if (![CLLocationManager locationServicesEnabled]) { | |
NSLog(@"Location services are not available (or are disabled for this app)."); | |
} | |
else { | |
self.locationManager = [[CLLocationManager alloc] init]; | |
self.locationManager.delegate = self; | |
self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; | |
self.locationManager.distanceFilter = 0; | |
if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { | |
NSLog(@"Running on iOS 8 or newer. Will request constant tracking authorization."); | |
[self.locationManager requestAlwaysAuthorization]; | |
} | |
else { | |
NSLog(@"Running on iOS 7 or older. Will attempt to start updating location immediately."); | |
[self.locationManager startMonitoringSignificantLocationChanges]; | |
[self.locationManager startUpdatingLocation]; | |
} | |
} | |
} | |
// omitted code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment