1

Following code doesnt works any more so what could we do

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"prefs:root=LOCATION_SERVICES"]];

Following works for Go to Settings → Your Application → Location but I want to access Go to Settings → Privacy → Location Services

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

I got the trouble same as below questions

Open Settings app from another app programmatically in iPhone

Community
  • 1
  • 1
Nischal Hada
  • 3,230
  • 3
  • 27
  • 57

1 Answers1

1

i use this code if user don't turn on location services

 - (void)locationManager:(CLLocationManager *)manager
   didFailWithError:(NSError *)error {
     if ([[error domain] isEqualToString: kCLErrorDomain] && [error code] == kCLErrorDenied) {
       // The user denied your app access to location information.

       UIAlertView* alert=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location" message:@"You can enable access in Settings" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil];
       alert.delegate = self;
       [alert show];
     }


    NSLog(@"%@", error.description);
}

and hanle Settings button in UIAlertView in this code:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   NSLog(@"buttonIndex:%d",buttonIndex);

   if (buttonIndex == 1) {
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
   }
}