Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ask permission from user for second time to allow to access the current location?

In my app, if the user not allowed to access their current location, I can recieve that message in the following method

- (void)locationManager:(CLLocationManager*)aManager didFailWithError:(NSError*)anError
{
    switch([anError code])
    {
       case kCLErrorLocationUnknown: 
        break;

        case kCLErrorDenied:
        {
           UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Access Denied" message:@"You didn't allow to access your current location" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
          break;
        }
    }
 }

How to ask the user permission for the second time?

I searched and got the answer NO, If the user wants the app to access his/her location, how he/she set the app to use their current location?

Is deleting the app and download another one the only solution?

like image 448
Nazik Avatar asked Jan 13 '23 20:01

Nazik


2 Answers

Is this just me or what? There are several questions like this. Each of which are answered by what the user should do to reenable the location service instead of what the the programmer should do to get that precious consistent alert.

call

[singleton.locationManager startUpdatingLocation];

That's actually what pops the alert.

If you don't call it, then the alert doesn't show up.

If you check first if it's enabled and then call it only if it's enabled, then the alert doesn't show up.

I spent weeks figuring this out. There is no info whatsoever about this in internet.

like image 138
user4234 Avatar answered Jan 19 '23 11:01

user4234


I think Yes. Deleting the app and download another one is the only solution as that alert message asking user's permission to access location settings is not getting fired by the app but by iPhone OS and hence in my opinion you can't ask it programatically.

like image 35
Yogi Avatar answered Jan 19 '23 12:01

Yogi