views:

96

answers:

0

I am using a method to create a location manager if it doesn't exist and start it. It checks if the user has location services disabled and respects that unless a BOOL is given to start the services anyway. The method returns a BOOL to indicate services have been started or not.

This works fine for starting the service and prompting the user the first time. If they tap allow things proceed as normal and if they tap don't allow I present a view to input location manually.

However I would like the user to be able to change their mind about using location services so I have a button to allow them to go back to using GPS. It calls the same function again, but this time ignores the users location services preference. I believe this should prompt the user to allow/disallow again, but I am getting an immediate kCLDenied error code instead.

Based on http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html#//apple_ref/doc/uid/TP40009497-CH2-SW11 I would expect another user prompt, not an immediate error.

- (BOOL)startLocationServices:(BOOL)ignorePrefs
{
//    
//    /*UNREVISEDCOMMENTS*/
//    
if (locationManager == nil)
{
    if ([CLLocationManager locationServicesEnabled] || ignorePrefs)
    {
        locationManager    =    [[CLLocationManager alloc] init];
        [locationManager setDelegate:self];
        [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
        [locationManager setDistanceFilter:10.0];
    }
    else
    {
        return NO;
    }
}
[locationManager startUpdatingLocation];
return YES;
}

(My location manager delegate releases and sets location manager to nil if a denied error is received.)