Подтвердить что ты не робот

Можно открыть приложение "Настройки" с помощью openURL?

Я знаю, что приложение может запускать другие приложения, используя этот код: [[UIApplication sharedApplication] openURL:appUrl];. И я знаю схему URL для открытия сафари и почты, но я сделал некоторые поиски и ничего не нашел о схеме settings.app.

4b9b3361

Ответ 1

Вы можете открывать приложения приложений программным способом, чтобы попробовать (работает только с iOS8 и далее).

Если вы используете Swift:

    UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString))

Если вы используете Objective-C

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

Для других более низких версий (менее iOS8) его невозможно запрограммировать при открытии настроек.

Ответ 2

Вы можете использовать это в версиях iOS 5.0 - 5.0.1. В iOS 5.1 он был устаревшим.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

Ответ 3

Приложения с программным обеспечением открытия программ программно возможны только с iOS 8. Итак, используйте следующий код http://code-ios.blogspot.in/2014/10/opening-settings-app-from-another-app.html

if([CLLocationManager locationServicesEnabled]&&
   [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied)
{
  //...Location service is enabled
}
else
{
    if([[[UIDevice currentDevice] systemVersion] floatValue]<8.0)
    {
    UIAlertView* curr1=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [curr1 show];
    }
    else
    {
        UIAlertView* curr2=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil];
        curr2.tag=121;
        [curr2 show];
    }
}

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

   if (alertView.tag == 121 && buttonIndex == 1)
 {
  //code for opening settings app in iOS 8
   [[UIApplication sharedApplication] openURL:[NSURL  URLWithString:UIApplicationOpenSettingsURLString]];
 }
}

Ответ 4

версия Swift 4:

if let url = URL(string: UIApplicationOpenSettingsURLString) {
    UIApplication.shared.openURL(url)
}