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

后端 未结 11 2236
死守一世寂寞
死守一世寂寞 2020-11-29 20:06

I have an application with an explicit user interaction that makes use of the user\'s current location. If the user denies access to location services, I would still like su

11条回答
  •  野性不改
    2020-11-29 20:28

    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]];
    }
    

提交回复
热议问题