How to programmatically check which international keyboards are installed on the iPhone?

I am working on an application where a user can search the database in several languages. I want to know which keyboards are installed on his device, if he does not have a specific one, I can show a pop-up window and explain to him how to install it. How to get it?

+4
source share
1 answer

You can find it in NSUserDefaults:

NSDictionary* defaults = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; 

I tested it on iOS Simulator (iOS 5.0). I have only the American keyboard installed. The contents of the default values:

 AppleITunesStoreItemKinds = ( eBook, document, "software-update", booklet, "itunes-u", newsstand, artist, podcast, "podcast-episode", software ); AppleLanguages = ( en, fr, de, ja, nl, it, es, pt, "pt-PT", da, fi, nb, sv, ko, "zh-Hans", "zh-Hant", ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, "en-GB", ca, hu, vi ); AppleLocale = "en_US"; NSInterfaceStyle = macintosh; NSLanguages = ( en, fr, de, ja, nl, it, es, pt, "pt-PT", da, fi, nb, sv, ko, "zh-Hans", "zh-Hant", ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, "en-GB", ca, hu, vi ); } 

Then I added a Russian keyboard, and the contents of NSUserDefaults will become:

 { AppleITunesStoreItemKinds = ( eBook, document, "software-update", booklet, "itunes-u", newsstand, artist, podcast, "podcast-episode", software ); AppleKeyboards = ( " en_US@hw =US;sw=QWERTY", " ru_RU@hw =Russian;sw=Russian" ); AppleKeyboardsExpanded = 1; AppleLanguages = ( en, fr, de, ja, nl, it, es, pt, "pt-PT", da, fi, nb, sv, ko, "zh-Hans", "zh-Hant", ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, "en-GB", ca, hu, vi ); AppleLocale = "en_US"; NSInterfaceStyle = macintosh; NSLanguages = ( en, fr, de, ja, nl, it, es, pt, "pt-PT", da, fi, nb, sv, ko, "zh-Hans", "zh-Hant", ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, "en-GB", ca, hu, vi ); } 

So you need to use AppleKeyboards and AppleKeyboardsExpanded .

+9
source

Source: https://habr.com/ru/post/1382259/


All Articles