iosios6user-permissionsuserlocation

How to check permission for userLocation


Is there a way to check if the user gave permission or not to my App use his/her location coordinates? I'd like check this before he/she press a button to submit some info, and I'll only activate this button if user gave permission.

My app uses iOS 6.

Thanks


Solution

  • In your delegate of the CLLocationManager instance, implement the

    - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
    

    method. If this method is called with its error parameter set to kCLErrorDenied, then the user has not enabled using the location services. You can also implement the

    - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
    

    method - when the status parameter of this callback method is not kCLAuthorizationStatusDenied, then the user has enabled your app to use his location.

    Documentation here.