简体   繁体   中英

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

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

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.

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"

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!

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;
    }
}
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];
     }
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM