问题描述
我想知道是否有一种方法可以让我从键盘容器应用程序检测相关键盘是否已在设备的设置"应用程序中激活.
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;
}
这篇关于如何检测是否从键盘的容器应用程序激活了自定义键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!