Is It Considered a Private API to Use App-Prefs:Root

My app rejected because uses the prefs:root= non-public URL scheme

Apple's message is pretty clear. There is only one legal way to open Settings, and that is to use UIApplication.openSettingsURLString.

Your app uses the “prefs:root=” non public URL scheme. Best plan to update old code?

I'm getting a Type 'UIApplication' has no member 'openSettingsURLString'

Well, you can see from the documentation that the type UIApplication does have this member. Here it is:

https://developer.apple.com/documentation/uikit/uiapplication/1623042-opensettingsurlstring

It is a static read-only property of UIApplication. (That is why it is not capitalized; it is a property.) And it is used like this:

let url = URL(string: UIApplication.openSettingsURLString)!
UIApplication.shared.open(url)

If you are not able to use it that way, it must be because you are using an outdated version of Swift. In that case, you would write:

let url = URL(string:UIApplicationOpenSettingsURLString)!
UIApplication.shared.open(url)

However, you should not be using such an outdated version of Swift. It is no crime, to be sure, but it certainly makes communication with the rest of us here on Stack Overflow difficult. By now, Xcode 10 and Swift 4.2 have been available for a long time, and you should upgrade to them so as to be on the same page with everyone else. Otherwise you're just trying to talk a different language from the rest of us — an older language that most of us have already forgotten. Not to mention the fact that you are out of sync with the online documentation, which does not show linguistic terms for older versions of the Swift language.

The prefs URL Scheme is not working in iOS 10 (Beta 1 & 2)

Just replace prefs to App-Prefs for iOS 10

Below code works for iOS 8,9,10

Swift 3.0 and Xcode >= 8.1

if #available(iOS 10.0, *)
{
UIApplication.shared.openURL(URL(string: "App-Prefs:root=SOMETHING")!)
}
else
{
UIApplication.shared.openURL(URL(string: "prefs:root=SOMETHING")!)
}

Swift 2.2

if #available(iOS 10.0, *)
{
UIApplication.sharedApplication().openURL(NSURL(string:"App-Prefs:root=SOMETHING")!)
}
else
{
UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=SOMETHING")!)
}

Works for me.

Happy Coding /p>


Related Topics



Leave a reply



Submit