In custom iOS keyboard detect the app

It is possible through following code. As you'll get bundle identifier of the app where you're using your custom keyboard.

Swift

    let hostBundleID = self.parentViewController!.valueForKey("_hostBundleID")
    let currentHostBundleID = String(hostBundleID)
    print(currentHostBundleID);

From bundle identifier you can find app name easily.


This is not possible. An extension runs sandboxed and is only fed information from the API and cannot access anything else. The keyboard can only receive text context changes and activate/deactivate calls. Being able to detect an app lies outside of the extension sandbox and therefore is impossible.