4

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?

Nazik
  • 8,696
  • 27
  • 77
  • 123
  • everyone did downvote for my answer... just check this you will get what i want to say.. http://stackoverflow.com/questions/14984168/how-to-resolve-a-core-location-logic-in-ios-app/14984754#14984754 – Rajneesh071 Mar 26 '13 at 07:44

5 Answers5

4

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.

user4234
  • 1,523
  • 1
  • 20
  • 37
3

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.

Yogi
  • 3,578
  • 3
  • 35
  • 56
2

I think you can turn on Location Services from device Settings -> Location Services tab.. See the image below

enter image description here

Update: When location services is off for an app, the location manager will fire error with error code kCLErrorDenied then you can show an alert to user to Turn On location services from settings..

Or, you can use the following code too

if (![CLLocationManager locationServicesEnabled])
iphonic
  • 12,615
  • 7
  • 60
  • 107
  • 2
    This has to be done by user. I think NAZIK is asking if the developer can ask the user to allow the access to location services or not. – Yogi Mar 26 '13 at 07:09
  • ie, we should inform the user to go to app settings to change the location services, is it? – Nazik Mar 26 '13 at 07:09
  • No, the best you can do is display a UIAlertView telling them to go through the process iphonic details when the location manager fails with a `kCLErrorDenied` error. The system alert is a one time deal AFAIK, (probably to stop developers from accidentally pestering users every time they spun up a CLLocationManager). – axiixc Apr 22 '13 at 02:54
0

You can reset location manually in your device Setting-->Privacy-->Location, then restart your app again.

Nazik
  • 8,696
  • 27
  • 77
  • 123
Rishi
  • 37
  • 1
0

This need to be done by users.

in ios 7: Settings->General->Restriction->turn on if not->Under privacy -Location services

Yiding
  • 2,914
  • 3
  • 21
  • 16