6

Here is my problem: I am working on an app that uses CloudKit. I need to hand the scenario that the user is not logged in to iCloud on the device. I would like to send them to the iCloud settings, and remind them that iCloud data needs to be turned on for my app. I am using NSFileManager.defaultManager().ubiquityIdentityToken to decide if I need to open the user's iCloud settings. The problem is, I can't figure out how. What is the URL for the device's iCloud settings? I have done a lot of research, and know I do not want UIApplicationOpenSettingsURLString. This open's the app's settings, not the devices. This is not made any easier with iOS 9's new security features, which I think I have set up properly:

enter image description here

Henry OM
  • 83
  • 7
  • 1
    Looks like this already has an answer here (it's not possible) http://stackoverflow.com/questions/25988241/url-scheme-open-settings-ios – inorganik Dec 31 '15 at 21:03
  • You can't open the Settings app other than for your own app's settings. And `LSApplicationQueriesSchemes` has nothing at all to do with this. – rmaddy Dec 31 '15 at 21:24
  • I was under the impression that LSApplicationQueriesSchemes is a way to whitelist URLs that have been blocked by default for security in iOS 9 – Henry OM Dec 31 '15 at 22:46
  • It's the list of URL schemes that you wish to use with calls to `UIApplication canOpenURL:`. What does that have to do with your question? – rmaddy Jan 01 '16 at 16:49
  • I thought I could open settings with this – Henry OM Jan 03 '16 at 21:26

1 Answers1

1

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, 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
  • 1
    I just had an app rejected for using `App-prefs:root`. "Your app uses the "prefs:root=" non-public URL scheme, which is a private entity. The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change." – Brad G. Jul 06 '18 at 20:26
  • when I code let iCloudURL = URL(string: "App-prefs:root=CASTLE") it brings me to the general settings widndow :/ – pistoleta Nov 18 '20 at 13:19