1

I have a specific situation in my app that presents a UIAlertView to a user with two buttons : Settings and Ask me Later. Ask Me Later is just a cancel, but I want the Settings to either:

1) Open up the iCloud section of the iOS Settings app 2) If that's not possible, just open up the Settings.

This is an iOS 7 only app and I've come across plenty of articles that's saying this has stopped being supported past iOS 5. I'd completely accept that if the Authy app didn't offer the same thing.

In their app, as can be seen in the screenshot below, you're presented with the ability to go to the Bluetooth section of the settings and it works. I'm sure other apps do it too.

My code below currently doesn't do anything:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex != [alertView cancelButtonIndex])
    {
        NSLog(@"Settings selected");

        NSURL*url=[NSURL URLWithString:@"prefs:root=General&path=Bluetooth"];
        [[UIApplication sharedApplication] openURL:url];

    }

Based on this Stack Overflow post (iOS UIAlertView button to go to Setting App) (which admittedly is old), I have tried most variations and I cannot get the Settings.app to open up. It doesn't do anything when I click on it.

If going to the iCloud section is not possible, I don't mind just sending the user to the Settings.app if that is possible?

Any thoughts would be appreciated.

enter image description here

Community
  • 1
  • 1
amitsbajaj
  • 1,304
  • 1
  • 24
  • 59
  • 1) Through iOS 7 there is no way to launch the Settings app (to any page). 2) What does the posted screenshot have to do with your question? – rmaddy Aug 14 '14 at 15:45
  • Thanks rmaddy - appreciate the response. The posted screenshot is highlighting that one app (Authy) is able to do this - by clicking on the Settings button, you're taken to the Bluetooth section of the Settings app and so I wanted to indicate that's what I was trying to achieve.. and that if they did it and they're not rejected in the App Store, there must be some way to achieve it.. – amitsbajaj Aug 14 '14 at 17:26
  • 1
    That's a system alert provided by iOS, not the app. – rmaddy Aug 14 '14 at 17:34
  • Ahh.. that makes perfect sense actually. I thought it was something the app was able to do but now that you mention it, a system alert makes perfect sense. My bad! Should I close this question, or do you want to answer it and I can just accept that? Thanks again though Rmaddy - was going crazy with why it wouldn't work for me – amitsbajaj Aug 14 '14 at 17:35

1 Answers1

0

You can launch iCloud section of the Settings App. I have tested this both on iOS 9.3 and 10.2.

The steps are as follows:

  1. Add a new URL Scheme to your app from the Project Settings/Info/URL Types.

enter image description here

  1. Now from your UIAlertView, you can open Settings/iCloud app with this code.

    let iCloudURL = URL(string: "App-prefs:root=CASTLE")
    if let settingsURL = iCloudURL {
         UIApplication.shared.openURL(settingsURL)
    }
    

Note for iOS 10.*: openURL method is actually deprecated and you should use the open with completion handler method:

open(_ url: URL, 
     options: [String : Any] = [:], 
     completionHandler completion: ((Bool) -> Void)? = nil)

References

Community
  • 1
  • 1
3d-indiana-jones
  • 879
  • 7
  • 17