How to Disable Custom Keyboards (Ios8) for My App

Can I disable custom keyboards (iOS8) for my app?

Looks like you got what you wanted in beta seed 3. Line 440 of UIApplication.h:

// Applications may reject specific types of extensions based on the extension point identifier.
// Constants representing common extension point identifiers are provided further down.
// If unimplemented, the default behavior is to allow the extension point identifier.
- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier NS_AVAILABLE_IOS(8_0);

It's not currently included in the docs, but sound like it will do exactly what you asked here.

I'm guessing these "extension point identifiers" are not unique identifiers of extensions, but of their types, as there is also this on line 545:

// Extension point identifier constants
UIKIT_EXTERN NSString *const UIApplicationKeyboardExtensionPointIdentifier NS_AVAILABLE_IOS(8_0);

TLDR: to disable custom keyboards you would include something like this in your app delegate:

- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier {
if ([extensionPointIdentifier isEqualToString: UIApplicationKeyboardExtensionPointIdentifier]) {
return NO;
}
return YES;
}

Is it possible for an app to disallow custom keyboard in iOS 8?

You can not use custom keyboard for secure input :

There are certain text input objects that your custom keyboard is not
eligible to type into. First is any secure text input object. Such an
object is defined by its secureTextEntry property being set to YES and
is distinguished by presenting typed characters as dots.

So getting password should not be possible.
Also iOS will prompt the user if a keyboard want internet access, this to make keyloggers more obvious.

To disable custom keyboard in your app completely override the application:shouldAllowExtensionPointIdentifier:

- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier {
// Disallow custom keyboards
return ![extensionPointIdentifier isEqualToString:UIApplicationKeyboardExtensionPointIdentifier];
}

Prevent custom keyboard in textfield

Using the answer from Pablo Ezequiel Romero as a starting point, I was able to get things to work for me. Essentially, rather than using a UIViewController for the custom keyboard, use a UIInputViewController and put your controls inside the UIInputViewController's inputView. Then, assign the inputView of your UITextField or UITextView to the inputView of the UIInputViewController.

If you're using auto layout, you need to make sure that you set everything properly and make sure to set an initial height constraint on the inputView and set its priority below the max 999 level (I used 800). Any height will do; the system will replace your constraint with one of its own. The lower priority avoids auto layout conflicts. (For me, if I didn't include this constraint, the final view wouldn't have any height at all.)

When I did all this, I was able to switch in and out of my (internal to the app) custom keyboard and any third-party keyboard extension.

How do you disable a 3rd party keyboard in your iOS app

Add this method to your UIApplicationDelegate

-(BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier
{

if (extensionPointIdentifier == UIApplicationKeyboardExtensionPointIdentifier)
{
return NO;
}

return YES;
}

Is a completely custom keyboard, for my app only, acceptable?

Totally acceptable inside your app! and there should be no acceptance criteria for that!

You can even make a custom keyboard to use outside your app (I developed two myself), however there are acceptance criteria for that (like having a button to switch to another keyboard).

Hope that helps!



Related Topics



Leave a reply



Submit