How can I force my app to use my custom keyboard?

1.8k views Asked by At

I've build a custom keyboard, but I don't want that the people to go to Settings > General. Select Keyboard and then click on Add Keyboard, I would like the people just open the app and when a certain text field get focused my custom keyboard appear.

How can I achieve this?

3

There are 3 answers

3
Yedidya Reiss On

You can not force the user to choose your keyboard. If it really matter, you may add a custom view as input for your textfield, and implement your keyboard in that view.

Good luck.

3
Ashish Kakkad On

You can not do it. User must have to select keyboard from the settings. You can not force to use your keyboard by the user.

For more check the documents provided by apple for the custom keyboard : https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html

There are some pros and cons also there.

1
Dharmesh Kheni On

Simply you can not force user to use your custom keyboard. If user select your custom keyboard form setting then they can use your custom keyboard but without selecting your custom keyboard from setting they can not use your custom keyboard.

If your textField need some special type of input then you can set keyboard for it by selecting your textField go to Attribute inspector at keyBoard type you can find some default Keyboard which is available by apple as shown in below Image:

enter image description here

You can use any of this keyboard from here.

And If you want to set it Programmatically you can do it this way:

yourTextField.keyboardType = .NumberPad

Here is a keyboardType property for a UITextField:

enum UIKeyboardType : Int {

    case Default // Default type for the current input method.
    case ASCIICapable // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
    case NumbersAndPunctuation // Numbers and assorted punctuation.
    case URL // A type optimized for URL entry (shows . / .com prominently).
    case NumberPad // A number pad (0-9). Suitable for PIN entry.
    case PhonePad // A phone pad (1-9, *, 0, #, with letters under the numbers).
    case NamePhonePad // A type optimized for entering a person's name or phone number.
    case EmailAddress // A type optimized for multiple email address entry (shows space @ . prominently).
    @availability(iOS, introduced=4.1)
    case DecimalPad // A number pad with a decimal point.
    @availability(iOS, introduced=5.0)
    case Twitter // A type optimized for twitter text entry (easy access to @ #)
    @availability(iOS, introduced=7.0)
    case WebSearch // A default keyboard type with URL-oriented addition (shows space . prominently).
}

Hope it will help you.