Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open your app in Settings iOS 11

Tags:

swift

ios11

It seems that Apple has moved a lot of the app configurations to the App path with iOS 11, how to open the app path programmatically in Settings? I tried "App-Prefs:root=\(Bundle.main.bundleIdentifier!)" but this doesn't seem to work.

Please note that my question is specific to: How to open the app path in settings: NOT how to open the settings

like image 809
Tal Zion Avatar asked Sep 26 '17 08:09

Tal Zion


People also ask

What is per-app settings iOS?

Apple has a little-used feature that can enhance Accessibility that's likely overlooked by most users: Per-App Settings. Go to Settings > Accessibility > Per-App Settings whether or not you have turned on any Accessibility features.


2 Answers

Here is the code you're looking for, I guess:

if let url = URL(string: UIApplicationOpenSettingsURLString) {     if UIApplication.shared.canOpenURL(url) {         UIApplication.shared.open(url, options: [:], completionHandler: nil)     } } 

And in addition, the updated version for swift 5 :

if let url = URL(string: UIApplication.openSettingsURLString) {     if UIApplication.shared.canOpenURL(url) {         UIApplication.shared.open(url, options: [:], completionHandler: nil)     } } 
like image 92
Damien Bannerot Avatar answered Sep 28 '22 15:09

Damien Bannerot


Swift 4.2, iOS 12

Opening just the settings is possible with the function below:

extension UIApplication {      ...      @discardableResult     static func openAppSettings() -> Bool {         guard             let settingsURL = URL(string: UIApplication.openSettingsURLString),             UIApplication.shared.canOpenURL(settingsURL)             else {                 return false         }          UIApplication.shared.open(settingsURL)         return true     } } 

Usage: UIApplication.openAppSettings()

But be careful to NOT use "non-public URL scheme", such as: prefs:root= or App-Prefs:root, because otherwise your app will be rejected. This happened to me recently since I was trying to have a deeplink to the wifi section in the settings.

like image 28
Alessandro Francucci Avatar answered Sep 28 '22 17:09

Alessandro Francucci