处理再次进入弹起权限弹窗

This commit is contained in:
2025-11-03 15:04:19 +08:00
parent c7021e382e
commit e4cebeac85
6 changed files with 55 additions and 16 deletions

View File

@@ -37,7 +37,7 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.keyBoardst.CustomKe
[Bugly startWithAppId:BuglyId config:buglyConfig];
///
dispatch_async(dispatch_get_main_queue(), ^{
UIViewController *top = [self kb_topMostViewController];
UIViewController *top = [UIViewController kb_topMostViewController];
if (top) {
Class mgrCls = NSClassFromString(@"KBKeyboardPermissionManager");
if (mgrCls && [mgrCls respondsToSelector:@selector(shared)]) {
@@ -56,6 +56,15 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.keyBoardst.CustomKe
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)setupRootVC{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
@@ -67,17 +76,6 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.keyBoardst.CustomKe
#pragma mark - Permission presentation
- (UIViewController *)kb_topMostViewController
{
UIViewController *root = self.window.rootViewController;
if (!root) return nil;
UIViewController *top = root;
while (top.presentedViewController) {
top = top.presentedViewController;
}
return top;
}
#pragma mark - Deep Link
@@ -103,7 +101,7 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.keyBoardst.CustomKe
//
BOOL loggedIn = ([AppleSignInManager shared].storedUserIdentifier.length > 0);
if (loggedIn) return;
UIViewController *top = [self kb_topMostViewController];
UIViewController *top = [UIViewController kb_topMostViewController];
if (!top) return;
[KBLoginSheetViewController presentIfNeededFrom:top];
}
@@ -123,7 +121,7 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.keyBoardst.CustomKe
- (void)kb_presentPermissionIfNeeded
{
BOOL enabled = KBIsKeyboardEnabled();
UIViewController *top = [self kb_topMostViewController];
UIViewController *top = [UIViewController kb_topMostViewController];
if (!top) return;
if ([top isKindOfClass:[KBPermissionViewController class]]) {
if (enabled) {