MaappeaL
MaappeaL

Reputation: 524

URL Scheme "Open Settings" ios

I know this question has been asked so many times. The answers say that this is not available in Xcode > 5.x. but I saw some apps that can use this(Go to Settings)(iOS7). Is there any way to do this? Is it available in Xcode 6? Facebook can detect both cellular data and wifi.

enter image description hereenter image description here

Upvotes: 27

Views: 53003

Answers (5)

user3069232
user3069232

Reputation: 8995

iOS 13, Swift 5.0

Syntax for open settings changed [again] a tiny bit.

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

Upvotes: 3

chawki
chawki

Reputation: 887

This is not possible anymore in iOS 11, we can just open Settings. Here a Swift 4 code snippet:

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

Upvotes: 3

BalestraPatrick
BalestraPatrick

Reputation: 10144

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)
}

Upvotes: 85

Pablo
Pablo

Reputation: 119

1.- Add URL Types enter image description here

2.- Use:

Objective - C

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]];

Swift

 UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=General")!)

3.- Other path find in this answer: iOS Launching Settings -> Restrictions URL Scheme

Upvotes: 7

pawel_d
pawel_d

Reputation: 487

Alerts on your screenshots are system alerts. The first occurs when app wants to use internet and have a blocked cellular data for application (and Wifi is not connected). The second occurs when an application wants to use location services, and you have turned off wifi. It is not possible control the display of these alerts.

In iOS 8 (Xcode 6) is the ability to open the settings directly from the application. Please read this topics: How to open Settings programmatically like in Facebook app?

Opening the Settings app from another app

Upvotes: 2

Related Questions