I am trying to update some old code to get it to work in IOS 8. I have read through
Location Services not working in iOS 8
but I am still very confused as to how to correctly implement the methodology.
I have added in
<key>NSLocationWhenInUseUsageDescription</key>
<string>The spirit of stack overflow is coders helping coders</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>I have learned more on stack overflow than anything else</string>
into the infoPlist.strings
but I am not sure how to update my code to get it to execute properly. Here is a copy of the old code that I am using. Can anyone provide insight on how to properly update this code in order to get it to work with IOS 8?
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
NSLog(@"%s", __PRETTY_FUNCTION__);
switch (status) {
case kCLAuthorizationStatusAuthorizedAlways:
{
NSLog(@"kCLAuthorizationStatusAuthorized");
// Re-enable the post button if it was disabled before.
self.navigationItem.rightBarButtonItem.enabled = YES;
[self.locationManager startUpdatingLocation];
}
break;
case kCLAuthorizationStatusDenied:
NSLog(@"kCLAuthorizationStatusDenied");
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Anywall can’t access your current location.\n\nTo view nearby posts or create a post at your current location, turn on access for Anywall to your location in the Settings app under Location Services." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertView show];
// Disable the post button.
self.navigationItem.rightBarButtonItem.enabled = NO;
}
break;
case kCLAuthorizationStatusNotDetermined:
{
NSLog(@"kCLAuthorizationStatusNotDetermined");
}
break;
case kCLAuthorizationStatusRestricted:
{
NSLog(@"kCLAuthorizationStatusRestricted");
}
break;
}
}
The code I am using here is from an old version of parse's Anywall Tutorial. I have tried adding in
case kCLAuthorizationStatusNotDetermined:
{
NSLog(@"kCLAuthorizationStatusNotDetermined");
[self.locationManager requestAlwaysAuthorization];
}
break;
In addition the application also displays the user's location on a map do I have to update that method as well?