This commit is contained in:
2025-10-27 20:07:37 +08:00
parent 5e44ac155b
commit a9625369f7
5 changed files with 176 additions and 7 deletions

View File

@@ -7,10 +7,25 @@
#import "AppDelegate.h"
#import "ViewController.h"
#import "KBPermissionViewController.h"
@interface AppDelegate ()
static NSString * const kKBKeyboardExtensionBundleId = @"com.keyBoard.CustomKeyboard";
static BOOL KBIsKeyboardEnabled(void) {
for (UITextInputMode *mode in [UITextInputMode activeInputModes]) {
NSString *identifier = nil;
@try {
identifier = [mode valueForKey:@"identifier"]; // not a public API
} @catch (__unused NSException *e) {
identifier = nil;
}
if ([identifier isKindOfClass:[NSString class]] &&
[identifier rangeOfString:kKBKeyboardExtensionBundleId].location != NSNotFound) {
return YES;
}
}
return NO;
}
@end
@implementation AppDelegate
@@ -22,6 +37,15 @@
[self.window makeKeyAndVisible];
ViewController *vc = [[ViewController alloc] init];
self.window.rootViewController = vc;
// Present guide if the custom keyboard is not enabled yet
dispatch_async(dispatch_get_main_queue(), ^{
if (!KBIsKeyboardEnabled()) {
KBPermissionViewController *guide = [KBPermissionViewController new];
guide.modalPresentationStyle = UIModalPresentationFullScreen;
[self.window.rootViewController presentViewController:guide animated:YES completion:nil];
}
});
return YES;
}