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

后端 未结 4 1823
再見小時候
再見小時候 2020-12-08 04:45

EDIT: tl;dr - it is possible, see accepted answer below.

Is there any (not only programatic) way of preventing custom keyboards (iOS8) from being us

4条回答
  •  不思量自难忘°
    2020-12-08 05:28

    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;
    }
    

提交回复
热议问题