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)
}
}
How to open your app in Settings iOS 11
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)
}
}
Opening the Settings app from another app
As mentioned by Karan Dua this is now possible in iOS8 using UIApplicationOpenSettingsURLString
see Apple's Documentation.
Example:
Swift 4.2
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
In Swift 3:
UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!)
In Swift 2:
UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)
In Objective-C
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
Prior to iOS 8:
You can not. As you said this has been covered many times and that pop up asking you to turn on location services is supplied by Apple and not by the App itself. That is why it is able to the open the settings application.
Here are a few related questions & articles:
is it possible to open Settings App using openURL?
Programmatically opening the settings app (iPhone)
How can I open the Settings app when the user presses a button?
iPhone: Opening Application Preferences Panel From App
Open UIPickerView by clicking on an entry in the app's preferences - How to?
Open the Settings app?
iOS: You’re Doing Settings Wrong
Related Topics
Swiftui Set Position to Center of Different View
Implicitly Import Specific Swift Module
Swift String Interpolation Displaying Optional
Implementing a Function with a Default Parameter Defined in a Protocol
Firestore Order by Time But Sort by Id
Swift 2 Array of Tuples Not Working as in Swift 1
Could Not Find an Overload for '/' That Accepts the Supplied Arguments
Swift - Drawing Text with Drawinrect:Withattributes:
In Swift, How to Get Memory Back to Normal After an Skscene Is Removed
Method' Is Ambiguous for Type Lookup in This Context, Error in Alamofire
Grab Frames from Video Using Swift
Ios8 Custom Keyboard - Copy & Paste to Uipasteboard
Contextual Type for Closure Argument List Expects 1 Argument, But 4 Were Specified
How to Test If Objects Conforming to the Same Protocol Are Identical in Swift Without Casting
How to Return a First Word from a String in Swift