iosswiftuikeyboard

How does one disable third party keyboards in Swift?


Basically that's it, I haven't found a way to disable third party keyboard in my app, although I know it's possible 'cos I've seen it in apps like 1Password.

Any ideas?


Solution

  • Add this code in your AppDelegate

    Swift 5

    func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplication.ExtensionPointIdentifier) -> Bool {
        if extensionPointIdentifier == UIApplication.ExtensionPointIdentifier.keyboard {
            return false
        }
        return true
    }
    

    Swift 4:

    func application(_ application: UIApplication, shouldAllowExtensionPointIdentifier extensionPointIdentifier: UIApplicationExtensionPointIdentifier) -> Bool {
        if extensionPointIdentifier == UIApplicationExtensionPointIdentifier.keyboard {
            return false
        }
        return true
    }
    

    Apple reference.