How to Open Settings Programmatically Like in Facebook App

How to open Settings programmatically like in Facebook app?

You can't, there is no API call to do this.

Only system dialogs, dialogs from Apple Frameworks, can open the settings app.
In iOS 5 there was a app url scheme to open the system dialog but Apple removed it later.


With the coming of iOS 8 you can open the settings dialog on your apps page.

if (&UIApplicationOpenSettingsURLString != NULL) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
else {
// Present some dialog telling the user to open the settings app.
}

iOS how to programmatically launch WIFI page from Settings App?

Now, using the UIApplicationOpenSettingsURLString you can get the URL used to open the Settings app.

Because this is iOS 8 only, on iOS 7 or earlier you will need to check this exists before using it (or your app will crash)

   if(&UIApplicationOpenSettingsURLString != nil)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}

Hope this helps you

Is there a way to find and change Facebook account's privacy settings programmatically?

No, there is no way to do this via any of the official APIs provided by Facebook.

If you got any app or service doing this, then they presumably must be doing it in some way that is explicitly not allowed, such as interacting with the web UI directly, or mimicking internal API calls, that were not meant for public consumption.

How to open general settings (not in the app settings) from the app in iOS 8?

You cannot open system apps in iOS. You can show them the path to the message though.

'Settings->General->Keyboard' etc in a modal whenever you wish to display this information to the user.

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

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

Open Settings app from another app programmatically in iPhone

Good news :

You can open settings apps programmatically like this (works only from iOS8 onwards).

If you are using Swift 3.0:

UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!)

If you are using Objective-C:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

For other lower versions (less than iOS8) its not possible to programatically open the settings app.



Related Topics



Leave a reply



Submit