Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 9: Deeplink to iCloud Settings

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

like image 973
Henry OM Avatar asked Dec 31 '15 20:12

Henry OM


1 Answers

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

  • Opening the Settings app from another app
  • https://apple.stackexchange.com/questions/42915/complete-documentation-of-the-ios-settings-apps-url-scheme
like image 171
3d-indiana-jones Avatar answered Nov 01 '22 18:11

3d-indiana-jones