Call the official *Settings* app from my app on iPhone

后端 未结 9 771
名媛妹妹
名媛妹妹 2020-11-28 23:51

At one point in my app, I would like to redirect the user to the official Settings app. If possible, I also want go straight to the Network section within

相关标签:
9条回答
  • 2020-11-29 00:08

    Bad news: As @Hlung and @jasongregori suggested, for iDevices whose OS version >= iOS 5.1 && < iOS 8.0, there is once again NO official/documented way to call the built-in Settings app from a third-party app. Period.

    0 讨论(0)
  • 2020-11-29 00:08

    Just an additional answer to add onto the one's addressing iOS8+. If you're supporting anything below 8, you should check to see if it's supported

    BOOL canGoToSettings = (UIApplicationOpenSettingsURLString != NULL);
    if (canGoToSettings)
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
    }
    
    0 讨论(0)
  • 2020-11-29 00:11

    For settings in iOS 9 this is worked for me.

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

    But make sure you add a url schemes in URL types in

    Info tab in app targets.

    0 讨论(0)
  • 2020-11-29 00:23

    From IOS 8 you can call the settings from within app with this:

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

    0 讨论(0)
  • 2020-11-29 00:25

    Calling the settings app from other app is possible only from iOS 8. So, use the following code

    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
    {
       if (alertView.tag == 121 && buttonIndex == 1)
     {
      //code for opening settings app in iOS 8
       [[UIApplication sharedApplication] openURL:[NSURL  URLWithString:UIApplicationOpenSettingsURLString]];
     }
    }
    
    0 讨论(0)
  • 2020-11-29 00:29

    As noted in the comments below, this is no longer possible in iOS version 5.1 and after.

    If you are on iOS 5.0, the following applies:

    This is now possible in iOS 5 using the 'prefs:' url scheme. It works from a web page or from an app.

    example urls:

    prefs:root=General
    prefs:root=General&path=Network
    

    sample usage:

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]]
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Network"]]
    
    0 讨论(0)
提交回复
热议问题