How to handle "Don't Allow" case?

Discussion in 'iOS Programming' started by arnieterm, Feb 17, 2009.

  1. macrumors regular

    Joined:
    Aug 28, 2008
    #1
    Hi
    While using the CoreLocation in an iphone application. The user is displayed the alert that "appname" would like to use your current location with options "Don't Allow" and "Ok".
    if user selects "Don't Allow" how can we handle this situation as locationserviceenabled property returns true.

    Thanks
    Arnieterm
     
  2. thread starter macrumors regular

    Joined:
    Aug 28, 2008
    #2
    It seems to me that I have to handle "didFailWithError" event of CLLocationManager as it returns kCLErrorDomain with error code 0. I think the below given code will handle this:
    Code:
    NSString* strError;
    	if([error domain]==kCLErrorDomain)
    	{
    		switch([error code])
    		{
    			case kCLErrorDenied:
    				strError=@"Location denied error";
                                                       //Should correspond to "Don't Allow"
    				break;
    			case kCLErrorLocationUnknown:
    				strError=@"Unknown location error";
    				break;
    			default:
    				strError=@"Generic Location Error";
    				break;
    		}
    	}
    
     

Share This Page