6

How to Open Keyboard's settings screen programmatically in iOS 10?

This code is not working in iOS 10

NSURL *keyboardSettingsURL = [NSURL URLWithString: @"prefs:root=General&path=Keyboard/KEYBOARDS"];
    [[UIApplication sharedApplication] openURL:keyboardSettingsURL];

and added URL Scheme

Rachit
  • 814
  • 9
  • 19

5 Answers5

5

It looks like this functionality has been disabled in iOS 10. I believe that https://developer.apple.com/library/content/qa/qa1924/_index.html is no longer valid. I checked several top keyboard apps and they have either been updated to no longer have a direct link to the preferences, or have a non-working button.

Dima
  • 23,484
  • 6
  • 56
  • 83
2

is work in iOS 10+

NSURL *keboardURL = [NSURL URLWithString: @"App-Prefs:root=General&path=Keyboard/KEYBOARDS"];
[[UIApplication sharedApplication] openURL:keyboardURL];

key points:

@"App-Prefs:root=General&path=Keyboard/KEYBOARDS"

DouSha
  • 21
  • 1
  • Is this working for iOS13. I tried but didn't work. Do we have to enable something in the xcodeprojecte.g. URL type? – Sumit utreja Aug 26 '20 at 09:01
0

You may need to add a URL Scheme to your project if you haven't already. Instructions and more details can be found at this Apple Q&A Reference. Hope this helps!

  • Have you tried using `"prefs:root=General&path=Keyboard"`instead of `"prefs:root=General&path=Keyboard/KEYBOARDS"`? – Alex Pojman Sep 09 '16 at 20:29
  • "prefs:root=General&path=Keyboard" is also not working – Rachit Sep 09 '16 at 20:58
  • 1
    Unfortunately, it's very possible that Apple may have removed this type of URL functionality from iOS 10. According to some of the comments [here](http://stackoverflow.com/questions/37399893/open-phone-settings-programmatically-in-ios9), it seems that there has been a history of Apple rejecting apps that use the "prefs:*" URL, so it would make sense if it was removed from iOS 10 – Alex Pojman Sep 09 '16 at 21:06
  • The URL provided clearly mentions that it is only allowed to do so from keyboard extensions. Using this under all other scenarios will cause app rejection. – DS. Sep 10 '16 at 05:36
  • I am using this for Keyboard Extension App – Rachit Sep 10 '16 at 06:13
0

In iOS 10, a new url is required. Try using this code which tests both urls :

NSArray* urlStrings = @[@"prefs:root=General&path=Keyboard/KEYBOARDS", @"App-Prefs:root=General&path=Keyboard/KEYBOARDS"];
for(NSString* urlString in urlStrings){
    NSURL* url = [NSURL URLWithString:urlString];
    if([[UIApplication sharedApplication] canOpenURL:url]){
        [[UIApplication sharedApplication] openURL:url];
        break;
    }
}
Drico
  • 1,284
  • 15
  • 33
0
For IOS-10 or higher,openURL is deprecated. use with completion handler like below.

NSString *settingsUrl= @"App-Prefs:root=General&path=Keyboard";
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0){
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:settingsUrl]]) {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:settingsUrl] options:@{} completionHandler:nil];
     }
 }