问题
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?
回答1:
I think you can turn on Location Services from device Settings -> Location Services tab.. See the image below
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])
回答2:
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.
回答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.
回答4:
This need to be done by users.
in ios 7: Settings->General->Restriction->turn on if not->Under privacy -Location services
回答5:
You can reset location manually in your device Setting-->Privacy-->Location, then restart your app again.
来源:https://stackoverflow.com/questions/15631109/how-to-ask-permission-from-user-for-second-time-to-allow-to-access-the-current-l