简体   繁体   中英

Have issue in get current user's location with my app on ios 6

My application is running fine on iOS 5, I get the normal user's location information. But when installing my app on iOS 6, my application can not get the user's location (I don't have the popup asking permission location, and in location services I don't have the icon of my app. Other apps like Instagram and Path have the icon of the app in the location services on iOS 6). When I use this code below to check this issue, NSlog shows: Unable to determine, possibly not available

I don't understand why this is the case. I've tried other apps like Instagram or Path. We still get the normal user's location. I studied iOS 6 change method delegate in CLLocationManagerDelegate , but I think that's not the reason because my application does not ask the permission to get the user's location.

if ([CLLocationManager locationServicesEnabled]) {
        NSLog(@"Location Services Enabled");
        switch ([CLLocationManager authorizationStatus]) {
            case kCLAuthorizationStatusAuthorized:
                NSLog(@"We have access to location services");
                break;
            case kCLAuthorizationStatusDenied:
                NSLog(@"Location services denied by user");
                break;
            case kCLAuthorizationStatusRestricted:
                NSLog(@"Parental controls restrict location services");
                break;
            case kCLAuthorizationStatusNotDetermined:
                NSLog(@"Unable to determine, possibly not available");
                break;
            default:
                break;
        }
    }
    else {
        NSLog(@"Location Services Are Disabled");
    }

I have the same problem. For my app this situation was generated because I check if locationServices is enabled and I start update location only if this is true ([self.locationManager startUpdatingLocation].)

+ (BOOL)locationServicesEnabled {
    if (([CLLocationManager locationServicesEnabled]) && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)) {
        return YES;
    } else {
        return NO;
    } 
}

[self.locationManager startUpdatingLocation] without the check looks fine, but it's possible to generate other problems.

I think your problem is, that you just check if location is available, but do not use it. So iOS never asks for permission, because it isn't used. Your check is working fine!

Use a tutorial like this one and it will work. So did I resolve it for me!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM