处理ios18从其他app用自己键盘 拉起主app的bug

其他问题
This commit is contained in:
2025-11-24 19:58:19 +08:00
parent 8e93f8f86f
commit 15e37841bb
20 changed files with 264 additions and 88 deletions

View File

@@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:app.tknb.net</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.loveKey.nyx</string>

View File

@@ -16,7 +16,7 @@
#import "KBFullAccessManager.h"
#import "KBSkinManager.h"
#import "KBSkinInstallBridge.h"
#import "KBExtensionAppLauncher.h"
#import "KBHostAppLauncher.h"
// 使 static kb_consumePendingShopSkin
@interface KeyboardViewController (KBSkinShopBridge)
@@ -213,21 +213,26 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
[self showFunctionPanel:NO];
return;
}
// // 1. UL Scheme
// // - /login entry=recharge
// // https://app.tknb.net/ul/login?src=keyboard&entry=recharge
// // - 宿 UL 退 kbkeyboardAppExtension://recharge?src=keyboard
// NSString *ulStr = [NSString stringWithFormat:@"%@?src=keyboard&entry=recharge", KB_UL_RECHARGE];
// NSURL *ul = [NSURL URLWithString:ulStr];
//
NSString *schemeStr = [NSString stringWithFormat:@"%@://recharge?src=keyboard", KB_APP_SCHEME];
NSURL *scheme = [NSURL URLWithString:schemeStr];
//
// if (!ul && !scheme) { return; }
//
// UIApplication App
BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:self.view];
// 1. schemekbkeyboardAppExtension://recharge?src=keyboard
NSString *urlStr = [NSString stringWithFormat:@"%@://recharge?src=keyboard", KB_APP_SCHEME];
NSURL *scheme = [NSURL URLWithString:urlStr];
if (!scheme) return;
// 2. extensionContext +
[KBExtensionAppLauncher openScheme:scheme
usingInputController:self
source:self.view
completion:^(BOOL success) {
if (!success) {
[KBHUD showInfo:KBLocalized(@"请切换到主App完成充值")];
}
}];
if (!ok) {
//
// XXX App /
}
}
- (void)keyBoardMainViewDidTapSettings:(KBKeyBoardMainView *)keyBoardMainView {

View File

@@ -7,7 +7,7 @@
#import "Masonry.h"
#import "KBResponderUtils.h" // UIInputViewController
#import "KBHUD.h"
#import "KBExtensionAppLauncher.h"
#import "KBHostAppLauncher.h"
@interface KBFullAccessGuideView ()
@property (nonatomic, strong) UIControl *backdrop;
@@ -157,31 +157,20 @@
#pragma mark - Actions
// KBResponderUtils.h
// App访 Scheme UL
// App访宿 UIApplication + Scheme
- (void)onTapGoEnable {
UIInputViewController *ivc = KBFindInputViewController(self);
if (!ivc) { [self dismiss]; return; }
// responder
UIResponder *start = ivc.view ?: (UIResponder *)self;
// SchemeApp openURL
// 使 App Scheme
// SchemeAppDelegate kbkeyboardAppExtension://settings
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@@//settings?src=kb_extension", KB_APP_SCHEME]];
// Universal Link AASA/Associated Domains KB_UL_BASE
NSURL *ul = [NSURL URLWithString:[NSString stringWithFormat:@"%@?src=kb_extension", KB_UL_SETTINGS]];
__weak typeof(self) weakSelf = self;
[KBExtensionAppLauncher openPrimaryURL:scheme
fallbackURL:ul
usingInputController:ivc
source:self
completion:^(BOOL ok) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) return;
if (ok) {
[strongSelf dismiss];
} else {
NSString *showInfo = [NSString stringWithFormat:KBLocalized(@"Follow: Settings → General → Keyboard → Keyboards → %@ → Allow Full Access"),AppName];
[KBHUD showInfo:showInfo];
}
}];
BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:start];
if (ok) {
[self dismiss];
} else {
NSString *showInfo = [NSString stringWithFormat:KBLocalized(@"Follow: Settings → General → Keyboard → Keyboards → %@ → Allow Full Access"),AppName];
[KBHUD showInfo:showInfo];
}
}
@end

View File

@@ -17,7 +17,7 @@
#import "KBSkinManager.h"
#import "KBAuthManager.h" //
#import "KBULBridgeNotification.h" // Darwin UL
#import "KBExtensionAppLauncher.h"
#import "KBHostAppLauncher.h"
#import "KBStreamTextView.h" //
#import "KBStreamOverlayView.h" //
#import "KBFunctionTagListView.h"
@@ -321,7 +321,7 @@ static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ivc.extensionContext openURL:ul completionHandler:^(__unused BOOL ok) {}];
});
// 500ms App 退 Scheme
// 500ms App 退 Scheme宿 UIApplication
self.kb_ulHandledFlag = NO;
NSUInteger token = ++self.kb_ulSeq;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@@ -329,14 +329,15 @@ static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/
if (self.kb_ulHandledFlag) return; // App
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@://login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)index, encodedTitle]];
if (!scheme) return;
[KBExtensionAppLauncher openScheme:scheme
usingInputController:ivc
source:self
completion:^(BOOL success) {
if (!success) {
[KBHUD showInfo:KBLocalized(@"请切换到主App完成登录")];
}
}];
UIResponder *start = ivc.view ?: (UIResponder *)self;
//
[ivc dismissKeyboard];
BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:start];
if (!ok) {
[KBHUD showInfo:KBLocalized(@"请切换到主App完成登录")];
}else{
}
});
return;
}
@@ -378,13 +379,16 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C
if (!ul) return;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@@//login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)indexPath.item, encodedTitle]];
[KBExtensionAppLauncher openPrimaryURL:ul
fallbackURL:scheme
usingInputController:ivc
source:self
completion:^(BOOL success) {
if (!success) {
// extensionContext UL
[ivc.extensionContext openURL:ul completionHandler:^(BOOL ok) {
if (ok) {
return;
}
// UL 宿 UIApplication + Scheme
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@@//login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)indexPath.item, encodedTitle]];
UIResponder *start = ivc.view ?: (UIResponder *)self;
BOOL ok2 = [KBHostAppLauncher openHostAppURL:scheme fromResponder:start];
if (!ok2) {
// 访宿 Manager
dispatch_async(dispatch_get_main_queue(), ^{
[[KBFullAccessManager shared] ensureFullAccessOrGuideInView:self];
@@ -402,6 +406,12 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C
// - iOS16+ App
// - iOS15
// viewDidLoad
// + 访访
if (![[KBFullAccessManager shared] hasFullAccess]) {
// 访
[[KBFullAccessManager shared] ensureFullAccessOrGuideInView:self];
return;
}
UIPasteboard *pb = [UIPasteboard generalPasteboard];
NSString *text = pb.string; //