Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Settings programmatically like in Facebook app?

I need to open Settings programmatically from within my app. I searched across SO but everywhere people say that it's impossible. But today I saw that it's implemented in Facebook app. There's a button on an UIAlertView and when you click it you open the Settings. So indeed this is possible to open Settings, I have witnessed this myself. But how to do that? Does anyone know how Facebook does that?

like image 736
Andrey Chernukha Avatar asked May 23 '14 08:05

Andrey Chernukha


People also ask

How do I open app settings in IOS Swift?

To open up the settings in Swift code, first get the URL from the openSettingsURLString property that Apple provides. Then open that URL using the openURL method. To put it on an alert dialog with two options, open settings or dismiss, you could follow this code example.


2 Answers

On iOS 8 you can open Settings programmatically!

Here is the code:

- (void)openSettings {     BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);     if (canOpenSettings) {         NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];         [[UIApplication sharedApplication] openURL:url];     } } 

If your app has it’s own settings bundle, the settings will be opened showing your app’s settings. If your app does not have a setting bundle, the main settings page will be shown.

like image 53
Vito Ziv Avatar answered Oct 03 '22 11:10

Vito Ziv


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.
}
like image 41
rckoenes Avatar answered Oct 03 '22 10:10

rckoenes