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
Delete Cell from Uicollectionview Without Reloading from Top
Peripheral and Central at the Same Time on iOS
Is There Any Limitation to Distribution of Apps in iOS Enterprise Program
How to Easily Support Light and Dark Mode with a Custom Color Used in My App
iOS - Uisplitviewcontroller with Storyboard - Multiple Master Views and Multiple Detail Views
Uilabel: Background Dependent Color
Core Location Not Working in iOS 8
Using Apple's Reachability to Check Remote Server Reachability in Swift
About Viewcontroller's "Viewdidload" and "Viewwillappear" Methods
Will Apps That Use Telprompt Be Rejected
Coreanimation - Opacity Fade in and Out Animation Not Working
Detect Moment When Newline Starts in Uitextview
Firebase Cocoapods Installation Not Working
Passing Data Between 2 Uiviewcontroller Using Delegate and Protocol
Swiftui Transitions: Scale from Some Frame - Like iOS Homescreen Is Doing When Opening an App
How to Migrate an Old Xcode Project to Use Swiftui