Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check programmatically what international keyboards are installed on iPhone?

I'm working on an app where the user can search a database with several languages. I want to know which keyboards are installed on his device, if he doesn't have a specific one I can show a popup and explain him how to install it. How to get it?

like image 529
Gilad Kedmi Avatar asked Jan 18 '23 05:01

Gilad Kedmi


1 Answers

You can find it in NSUserDefaults:

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

I tested it on iOS Simulator (iOS 5.0). I have only US keyboard installed. Contents of defaults:

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 russian keyboard and contents of NSUserDefaults 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 keys.

like image 164
Aliaksandr Andrashuk Avatar answered Feb 19 '23 07:02

Aliaksandr Andrashuk