Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Keyboard's settings screen in iOS's settings app programmatically from another app

How can we go directly to any of the below mentioned screens of iOS's settings app programmatically

Keyboard Screen enter image description here

like image 889
iHulk Avatar asked Oct 28 '15 10:10

iHulk


2 Answers

UPDATE

As other users have pointed out this solution does not work anymore with iOS10. If anyone has an idea how to make it work in iOS10, please let us know.

Solution for iOS < 10:

To open the settings (of your own app) you can use the UIApplicationOpenSettingsURLString constant:

if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString) {
    UIApplication.sharedApplication().openURL(settingsURL)
}

This was introduced in iOS 8, so you can use it on devices that run iOS8 or later. But this only opens the settings of your own app. Not the keyboard settings. And if your app does not have its own settings it only opens the Settings app on its main page.

In the old days (before iOS 5.1) you could open a settings URL and directly go to almost any subpage in the Settings app. Apple removed this feature in iOS 5.1.

However it seems to work again in iOS 8 and 9. It is not officially documented by Apple but it seems to work, although I not sure how reliable this is. It works on my iOS 9.1 iPhone but not in the Simulator.

So, with caution, you can try this to open the Keyboard Settings:

if let settingsURL = NSURL(string: "prefs:root=General&path=Keyboard") {
    UIApplication.sharedApplication().openURL(settingsURL)
}

Or go even deeper:

if let settingsURL = NSURL(string: "prefs:root=General&path=Keyboard/KEYBOARDS") {
    UIApplication.sharedApplication().openURL(settingsURL)
}

Edit: As iHulk mentioned in the comments you might have to add prefs to the URL schemes in your project's Info.plist file to make this work.

like image 121
joern Avatar answered Nov 10 '22 15:11

joern


As of iOS 10 "App-Prefs:root" should be used rather than "prefs:root". See below Objective C code. Tested this , code works fine but Apple may reject the app because of this.
Note : As pointed out this will work only on ios 10

 NSString *settingsUrl= @"App-Prefs:root=General&path=Keyboard";

 if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) {

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:settingsUrl] options:@{} completionHandler:^(BOOL success) {
    NSLog(@"URL opened");
    }];
}
like image 26
Ankit J Avatar answered Nov 10 '22 16:11

Ankit J