Reputation: 6662
I'm trying to add a button to quickly access the iCloud Keychain. I'm aware that it isn't allowed on the App Store, that is fine.
Based on this article I found the preferred deep link for iOS Settings > Passwords,
prefs:root=PASSWORDS&search=$query
. I added the prefs
value to my "Queried URL Schemes" in info.plist
as well.
Despite this, the app fails to open my URL and throws this error:
Failed to open URL prefs:root=PASSWORDS: Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)" UserInfo={_LSLine=244, _LSFunction=-[_LSDOpenClient openURL:fileHandle:options:completionHandler:]}
This error is given when omitting the "search" parameter too.
Any idea on how I can accomplish this?
Upvotes: 3
Views: 790
Reputation: 13838
Apple changes the Settings app scheme names, paths, parameters etc. very often. While some older versions of the Settings app support prefs:
scheme, new ones support App-prefs:
so in your case for opening the Settings Passwords you should try the latter:
let url = URL(string: "App-prefs:PASSWORDS&search=your-domain.com")!
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}
Also you can use a more generic solution in order to support all known schemes:
func openSettings(path: String) {
let schemes = [
"App-prefs:",
"App-prefs:root=",
"prefs:",
"prefs:root=",
]
for scheme in schemes {
let url = URL(string: "\(scheme)\(path)")!
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
break
}
}
}
openSettings(path: "PASSWORDS&search=your-domain.com")
Upvotes: 1