2
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
#import "KBLoginSheetViewController.h"
|
||||
#import "AppleSignInManager.h"
|
||||
#import <objc/message.h>
|
||||
#import "KBULBridge.h" // Darwin 通知常量:用于通知扩展“UL已处理”
|
||||
#import "LSTPopView.h"
|
||||
#import "KBLoginPopView.h"
|
||||
|
||||
// 注意:用于判断系统已启用本输入法扩展的 bundle id 需与扩展 target 的
|
||||
// PRODUCT_BUNDLE_IDENTIFIER 完全一致。
|
||||
@@ -69,7 +72,14 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
||||
if ([host hasSuffix:@"app.tknb.net"]) {
|
||||
NSString *path = url.path.lowercaseString ?: @"";
|
||||
if ([path hasPrefix:@"/ul/settings"]) { [self kb_openAppSettings]; return YES; }
|
||||
if ([path hasPrefix:@"/ul/login"]) { [self kb_presentLoginSheetIfNeeded]; return YES; }
|
||||
if ([path hasPrefix:@"/ul/login"]) {
|
||||
// 通知扩展:UL 已被主 App 接收,扩展可取消回退到 Scheme
|
||||
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(),
|
||||
(__bridge CFStringRef)KBDarwinULHandled,
|
||||
NULL, NULL, true);
|
||||
[self kb_presentLoginSheetIfNeeded];
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
@@ -83,6 +93,10 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
||||
NSString *urlHost = url.host ?: @"";
|
||||
NSString *host = [urlHost lowercaseString];
|
||||
if ([host isEqualToString:@"login"]) { // kbkeyboard://login
|
||||
// 兜底路径:Scheme 也发一次“已处理”通知,避免扩展重复尝试
|
||||
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(),
|
||||
(__bridge CFStringRef)KBDarwinULHandled,
|
||||
NULL, NULL, true);
|
||||
[self kb_presentLoginSheetIfNeeded];
|
||||
return YES;
|
||||
} else if ([host isEqualToString:@"settings"]) { // kbkeyboard://settings
|
||||
@@ -100,7 +114,37 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
||||
if (loggedIn) return;
|
||||
UIViewController *top = [UIViewController kb_topMostViewController];
|
||||
if (!top) return;
|
||||
[KBLoginSheetViewController presentIfNeededFrom:top];
|
||||
// [KBLoginSheetViewController presentIfNeededFrom:top];
|
||||
[self goLogin];
|
||||
|
||||
}
|
||||
|
||||
- (void)goLogin{
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
KBLoginPopView *view = [[KBLoginPopView alloc] initWithFrame:CGRectMake(0, 0, KB_SCREEN_WIDTH, KB_SCREEN_WIDTH)];
|
||||
// 创建并弹出
|
||||
LSTPopView *pop = [LSTPopView initWithCustomView:view
|
||||
parentView:nil
|
||||
popStyle:LSTPopStyleSmoothFromBottom
|
||||
dismissStyle:LSTDismissStyleSmoothToBottom];
|
||||
pop.hemStyle = LSTHemStyleBottom;
|
||||
pop.bgColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
|
||||
pop.isClickBgDismiss = YES; // 点击背景关闭
|
||||
pop.cornerRadius = 0; // 自定义 view 自处理圆角
|
||||
|
||||
__weak typeof(pop) weakPop = pop;
|
||||
view.appleLoginHandler = ^{
|
||||
[weakPop dismiss];
|
||||
[[AppleSignInManager shared] signInFromViewController:KB_CURRENT_NAV completion:^(ASAuthorizationAppleIDCredential * _Nullable credential, NSError * _Nullable error) {
|
||||
NSLog(@"=====");
|
||||
}];
|
||||
};
|
||||
view.closeHandler = ^{ [weakPop dismiss]; };
|
||||
|
||||
[pop pop];
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)kb_openAppSettings {
|
||||
|
||||
Reference in New Issue
Block a user