This commit is contained in:
2025-11-03 16:57:24 +08:00
parent 1673a2f4be
commit 915b329805
7 changed files with 187 additions and 98 deletions

View File

@@ -35,35 +35,11 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.keyBoardst.CustomKe
/// GroupID
// buglyConfig.applicationGroupIdentifier = @"";
[Bugly startWithAppId:BuglyId config:buglyConfig];
///
dispatch_async(dispatch_get_main_queue(), ^{
UIViewController *top = [UIViewController kb_topMostViewController];
if (top) {
Class mgrCls = NSClassFromString(@"KBKeyboardPermissionManager");
if (mgrCls && [mgrCls respondsToSelector:@selector(shared)]) {
id mgr = [mgrCls performSelector:@selector(shared)];
if ([mgr respondsToSelector:@selector(presentPermissionIfNeededFrom:)]) {
// API
void (*func)(id, SEL, UIViewController *) = (void (*)(id, SEL, UIViewController *))objc_msgSend;
func(mgr, @selector(presentPermissionIfNeededFrom:), top);
}
} else {
//
[self kb_presentPermissionIfNeeded];
}
}
});
// KBGuideVC
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application{
// When returning from Settings, re-check the keyboard enable state
// and hide the guide if the user has enabled our keyboard.
// Also shows the guide again if still not enabled.
dispatch_async(dispatch_get_main_queue(), ^{
[self kb_presentPermissionIfNeeded];
});
}
- (void)applicationDidBecomeActive:(UIApplication *)application{}
- (void)setupRootVC{
@@ -120,20 +96,7 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.keyBoardst.CustomKe
- (void)kb_presentPermissionIfNeeded
{
BOOL enabled = KBIsKeyboardEnabled();
UIViewController *top = [UIViewController kb_topMostViewController];
if (!top) return;
if ([top isKindOfClass:[KBPermissionViewController class]]) {
if (enabled) {
[top dismissViewControllerAnimated:YES completion:nil];
}
return;
}
if (!enabled) {
KBPermissionViewController *guide = [KBPermissionViewController new];
guide.modalPresentationStyle = UIModalPresentationFullScreen;
[top presentViewController:guide animated:YES completion:nil];
}
// KBGuideVC
}