How can I prompt the user to turn on location services after user has denied their use How can I prompt the user to turn on location services after user has denied their use ios ios

How can I prompt the user to turn on location services after user has denied their use


With iOS8, you can finally link user to Settings app via openURL. For example, you can create a UIAlertView with a single button that takes user to the Settings app:

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:ICLocalizedString(@"LocationServicesPermissionTitle")                                                    message:ICLocalizedString(@"LocationPermissionGeoFenceMessage")                                                   delegate:self                                          cancelButtonTitle:@"Settings"                                          otherButtonTitles:nil];    [alert show];

In your UIAlertView delegate:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {    [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];    [[UIApplication sharedApplication] openURL: [NSURL URLWithString: UIApplicationOpenSettingsURLString]];}


Update:

As of iOS 8, there is now the constant UIApplicationOpenSettingsURLString which represents a URL that, when opened, opens the Settings app to your application's settings (where the user can then re-enable location services).


Original:

There is no way for you to do this. Your only real option is to display an alert informing the user that your application requires location services, and instructing them to manually go to the Settings app and turn it on.


AlertViews are deprecated in iOS 8. There is now a better way to handle alerts using the new AlertController:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString( @"Enter your title here", @"" ) message:NSLocalizedString( @"Enter your message here.", @"" ) preferredStyle:UIAlertControllerStyleAlert];UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString( @"Cancel", @"" ) style:UIAlertActionStyleCancel handler:nil];UIAlertAction *settingsAction = [UIAlertAction actionWithTitle:NSLocalizedString( @"Settings", @"" ) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:                                                    UIApplicationOpenSettingsURLString]];}];[alertController addAction:cancelAction];[alertController addAction:settingsAction];[self presentViewController:alertController animated:YES completion:nil];