如何检测是否从键盘的容器应用程序激活了自定义键盘?

How to detect whether custom keyboard is activated from the keyboard#39;s container app?(如何检测是否从键盘的容器应用程序激活了自定义键盘?)
本文介绍了如何检测是否从键盘的容器应用程序激活了自定义键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想知道是否有一种方法可以让我从键盘容器应用程序检测相关键盘是否已在设备的设置"应用程序中激活.

I was wondering if there is a method that would allow me to detect from the keyboard container app whether the associated keyboard has been activated in the the device's Settings app.

例如,我有兴趣在容器应用程序中添加一个简单的步骤"功能,其中步骤 1 将是激活键盘",而步骤 2 将取决于步骤 1 的完成情况.因此,我有兴趣弄清楚是否有办法检测键盘扩展是否被激活?

For example, I am interested in adding a simple "steps" feature inside the container app where step 1 would be "activate the keyboard", and step 2 would be contingent on step 1's completion. As such, I am interested in figuring out whether there is a way to detect whether the keyboard extension is activated?

谢谢!

推荐答案

这是我在一个项目中使用的一种方法.我认为这是您所要求的,希望对您有所帮助.

Here is a method I have used in one of my projects. I think it is what you asked for, hope it helps you.

- (BOOL)isCustomKeyboardEnabled {
    NSString *bundleID = @"com.company.app.customkeyboard"; // Replace this string with your custom keyboard's bundle ID
    NSArray *keyboards = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] objectForKey:@"AppleKeyboards"]; // Array of all active keyboards
    for (NSString *keyboard in keyboards) {
        if ([keyboard isEqualToString:bundleID])
            return YES;
    }

    return NO;
}

这篇关于如何检测是否从键盘的容器应用程序激活了自定义键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

No resource found that matches the given name: attr #39;android:keyboardNavigationCluster#39;. when updating to Support Library 26.0.0(找不到与给定名称匹配的资源:attr android:keyboardNavigationCluster.更新到支持库 26.0.0 时) - IT屋-程序员软
How to resize UITextView on iOS when a keyboard appears?(出现键盘时如何在iOS上调整UITextView的大小?)
How to reliably detect if an external keyboard is connected on iOS 9?(如何可靠地检测 iOS 9 上是否连接了外部键盘?)
How to mimic Keyboard animation on iOS 7 to add quot;Donequot; button to numeric keyboard?(如何在 iOS 7 上模拟键盘动画以添加“完成数字键盘的按钮?)
How do I dismiss the iOS keyboard?(如何关闭 iOS 键盘?)
Is possible to simulate touch event using an external keyboard on ios jailbroken?(是否可以在 ios 越狱后使用外部键盘模拟触摸事件?)