2
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user