URL Scheme Open Settings ios
As of iOS 8, it's possible to launch the Settings app that directly opens your Privacy app section in this way:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
In Swift:
if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString) {
UIApplication.sharedApplication().openURL(settingsURL)
}
In Swift 3.0:
if let settingsURL = URL(string: UIApplicationOpenSettingsURLString + Bundle.main.bundleIdentifier!) {
UIApplication.shared.openURL(settingsURL as URL)
}
How to open your app's settings (inside the Settings app) with Swift (iOS 11)?
Oops, it seems it works in iOS 11.4.1:
if let url = URL(string:UIApplicationOpenSettingsURLString) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
Custom URL Scheme for Settings on iOS 10?
None of the previous methods for launching the root "Settings" app on iOS 8+ were officially supported by Apple, so unfortunately we can't rely on them. It's also possible that apps that relied on the undocumented behaviors could be rejected during App Store review, even if others have been approved--even if the same app had been previously approved!
I've been unable to discover any workaround either, so it seems your choices are:
Open the app-specific URL (as detailed in many places, including @alvin-varghese 's answer above), and then ask the user to navigate backwards. (A terrible user experience, since it involves the user knowing to scroll up from the app list into the main settings sections.)
Use an instructional screen or alert in your app to educate users on how to find it themselves. (Not much better, but at least aren't dropped into an unfamiliar context with no waypoints.)
There doesn't seem to be an officially supported way of making this happen in iOS 10, and as you pointed out, it seems like the old ways (adding prefs
scheme to your Info.plist file and using openURL(_:)
) do not work any more.
iOS Launching Settings - Restrictions URL Scheme
AS @Nix Wang's ANSWER THIS IS NOT WORK IN IOS 10
WARNING: This method will not work for devices running iOS 5.1 and greater - See Hlung's comment below.
It's possible that the path
component has a different name than the actual section, but it's also possible that you can't currently access that section straight from a URL. I found a list of possible URLs and Restrictions is not on it, maybe it's just not found out yet.
List of currently known URLs in the Settings app:
- prefs:root=General&path=About
- prefs:root=General&path=ACCESSIBILITY
- prefs:root=AIRPLANE_MODE
- prefs:root=General&path=AUTOLOCK
- prefs:root=General&path=USAGE/CELLULAR_USAGE
- prefs:root=Brightness
- prefs:root=General&path=Bluetooth
- prefs:root=General&path=DATE_AND_TIME
- prefs:root=FACETIME
- prefs:root=General
- prefs:root=General&path=Keyboard
- prefs:root=CASTLE
- prefs:root=CASTLE&path=STORAGE_AND_BACKUP
- prefs:root=General&path=INTERNATIONAL
- prefs:root=LOCATION_SERVICES
- prefs:root=ACCOUNT_SETTINGS
- prefs:root=MUSIC
- prefs:root=MUSIC&path=EQ
- prefs:root=MUSIC&path=VolumeLimit
- prefs:root=General&path=Network
- prefs:root=NIKE_PLUS_IPOD
- prefs:root=NOTES
- prefs:root=NOTIFICATIONS_ID
- prefs:root=Phone
- prefs:root=Photos
- prefs:root=General&path=ManagedConfigurationList
- prefs:root=General&path=Reset
- prefs:root=Sounds&path=Ringtone
- prefs:root=Safari
- prefs:root=General&path=Assistant
- prefs:root=Sounds
- prefs:root=General&path=SOFTWARE_UPDATE_LINK
- prefs:root=STORE
- prefs:root=TWITTER
- prefs:root=General&path=USAGE
- prefs:root=VIDEO
- prefs:root=General&path=Network/VPN
- prefs:root=Wallpaper
- prefs:root=WIFI
- prefs:root=INTERNET_TETHERING
React Native Open settings through Linking.openURL in IOS
You can deep-link referencing the settings's index like so:
Linking.openURL('app-settings:')
Above method only for IOS
iOS prefs url scheme for touch id & passcode settings
if let url = URL(string: "App-Prefs:root=TOUCHID_PASSCODE") {
UIApplication.shared.openURL(url)
}
this works on IOS 10.2. However I'm not sure if apple rejects this or not. Has anyone had any issues with their submission using this?
How do I open phone settings when a button is clicked?
Using UIApplication.openSettingsURLString
Update for Swift 5.1
override func viewDidAppear(_ animated: Bool) {
let alertController = UIAlertController (title: "Title", message: "Go to Settings?", preferredStyle: .alert)
let settingsAction = UIAlertAction(title: "Settings", style: .default) { (_) -> Void in
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: \(success)") // Prints true
})
}
}
alertController.addAction(settingsAction)
let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: nil)
alertController.addAction(cancelAction)
present(alertController, animated: true, completion: nil)
}
Swift 4.2
override func viewDidAppear(_ animated: Bool) {
let alertController = UIAlertController (title: "Title", message: "Go to Settings?", preferredStyle: .alert)
let settingsAction = UIAlertAction(title: "Settings", style: .default) { (_) -> Void in
guard let settingsUrl = URL(string: UIApplicationOpenSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: \(success)") // Prints true
})
}
}
alertController.addAction(settingsAction)
let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: nil)
alertController.addAction(cancelAction)
present(alertController, animated: true, completion: nil)
}
Related Topics
How to Delete Derived Data and Clean Project in Xcode 5 and Later
Implementing Auto Layout for Views Generated Programmatically
Convert JSON String to JSON Object in Swift 4
Hide Dots from Uipageviewcontroller
Get Email and Name Facebook Sdk V4.4.0 Swift
Issue with Auto Layout on iOS 8 (Code Works Perfectly on iOS 7)
Swift - Coredata Migration - Set New Attribute Value According to Old Attribute Value
iOS Glsl. How to Create an Image Histogram Using a Glsl Shader
Number of Days in the Current Month Using iOS
Crashlytics iOS - Log Caught Exception
Saving Coredata To-Many Relationships in Swift
Ios: Perform Upload Task While App Is in Background
Error: Module File's Minimum Deployment Target Is iOS8.3 V8.3
Programmatically Get Path to Application Support Folder
Are Afnetworking Success/Failure Blocks Invoked on the Main Thread