Skip to content

Instantly share code, notes, and snippets.

@nfarah86
Created May 5, 2016 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfarah86/c3d78fb0b2d9d8255609bb4b45787291 to your computer and use it in GitHub Desktop.
Save nfarah86/c3d78fb0b2d9d8255609bb4b45787291 to your computer and use it in GitHub Desktop.
Get User's Location
// 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