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

时间:2023-02-01
本文介绍了如何检测是否从键盘的容器应用程序激活了自定义键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

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

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

上一篇:iPhone/iOS:为邮政编码呈现 HTML 5 键盘 下一篇:iPhone - 键盘隐藏文本字段

相关文章

最新文章