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
Drawing Class Drawing Straight Lines Instead of Curved Lines
Undefined Symbols for Architecture X86_64 on Xcode 6.1
Ibeacon: Didrangebeacons Stops Getting Called, Must Reset Device for It to Work Again
Nsurlconnection Sendasynchronousrequest Can't Get Variable Out of Closure
How to Recognize Which Pin Was Tapped
How to Capitalize Each Word in a String Using Swift iOS
Xcode Is Looking for Core Data Entity Names with Dot; Not Compiling
Uitableview and Uiview with Keyboardwillshow
Swift Equivalent to '[Nsdictionary Initwithobjects: Forkeys:]'
Foreign Key Relationship Mapping with Restkit
Iad Is Shutting Down. Should I Remove the Iad Framework from All My Applications
Extract Uiimage from Nsattributed String
Changing Vc Issue in Swift. How to Pass Data Between Views in Tab Bar Controller
Update Restkit 'Lcl_Rk.H' File Not Found in Rklog.H
How to Insert the Uitextview into Uialertview in iOS
What Is the '' Is or the ':' at the Equation When Coding in Swift
Achieving Bright, Vivid Colors for an iOS 7 Translucent Uinavigationbar