封装跨应用拉起,
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#import "KBFullAccessManager.h"
|
#import "KBFullAccessManager.h"
|
||||||
#import "KBSkinManager.h"
|
#import "KBSkinManager.h"
|
||||||
#import "KBSkinInstallBridge.h"
|
#import "KBSkinInstallBridge.h"
|
||||||
|
#import "KBExtensionAppLauncher.h"
|
||||||
|
|
||||||
// 提前声明一个类别,使编译器在 static 回调中识别 kb_consumePendingShopSkin 方法。
|
// 提前声明一个类别,使编译器在 static 回调中识别 kb_consumePendingShopSkin 方法。
|
||||||
@interface KeyboardViewController (KBSkinShopBridge)
|
@interface KeyboardViewController (KBSkinShopBridge)
|
||||||
@@ -206,13 +207,25 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyBoardMainView:(KBKeyBoardMainView *)keyBoardMainView didTapToolActionAtIndex:(NSInteger)index {
|
- (void)keyBoardMainView:(KBKeyBoardMainView *)keyBoardMainView didTapToolActionAtIndex:(NSInteger)index {
|
||||||
if (index == 0) {
|
if (index != 0) {
|
||||||
/// 充值操作
|
|
||||||
[KBHUD showInfo:KBLocalized(@"Recharge Now")];
|
|
||||||
// [self showFunctionPanel:YES];
|
|
||||||
} else {
|
|
||||||
[self showFunctionPanel:NO];
|
[self showFunctionPanel:NO];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1. 构造自定义 scheme:kbkeyboardAppExtension://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完成充值")];
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyBoardMainViewDidTapSettings:(KBKeyBoardMainView *)keyBoardMainView {
|
- (void)keyBoardMainViewDidTapSettings:(KBKeyBoardMainView *)keyBoardMainView {
|
||||||
|
|||||||
36
CustomKeyboard/Utils/KBExtensionAppLauncher.h
Normal file
36
CustomKeyboard/Utils/KBExtensionAppLauncher.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// KBExtensionAppLauncher.h
|
||||||
|
// CustomKeyboard
|
||||||
|
//
|
||||||
|
// 封装:在键盘扩展中拉起主 App(Scheme / Universal Link + 响应链兜底)。
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface KBExtensionAppLauncher : NSObject
|
||||||
|
|
||||||
|
/// 通用入口:优先尝试 primaryURL,失败后尝试 fallbackURL,
|
||||||
|
/// 两者都失败时再通过响应链(openURL:)做兜底。
|
||||||
|
/// - Parameters:
|
||||||
|
/// - primaryURL: 第一优先尝试的 URL(可为 Scheme 或 UL)
|
||||||
|
/// - fallbackURL: 失败时的备用 URL(可为 nil)
|
||||||
|
/// - ivc: 当前的 UIInputViewController(用于 extensionContext openURL)
|
||||||
|
/// - source: 兜底时用作起点的 responder(通常传 self 或 self.view)
|
||||||
|
/// - completion: 最终是否“看起来已成功发起”打开动作(不保证一定跳转到 App)
|
||||||
|
+ (void)openPrimaryURL:(NSURL * _Nullable)primaryURL
|
||||||
|
fallbackURL:(NSURL * _Nullable)fallbackURL
|
||||||
|
usingInputController:(UIInputViewController *)ivc
|
||||||
|
source:(UIResponder *)source
|
||||||
|
completion:(void (^ _Nullable)(BOOL success))completion;
|
||||||
|
|
||||||
|
/// 简化版:只针对单一 Scheme 做尝试 + 响应链兜底。
|
||||||
|
+ (void)openScheme:(NSURL *)scheme
|
||||||
|
usingInputController:(UIInputViewController *)ivc
|
||||||
|
source:(UIResponder *)source
|
||||||
|
completion:(void (^ _Nullable)(BOOL success))completion;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
121
CustomKeyboard/Utils/KBExtensionAppLauncher.m
Normal file
121
CustomKeyboard/Utils/KBExtensionAppLauncher.m
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
//
|
||||||
|
// KBExtensionAppLauncher.m
|
||||||
|
// CustomKeyboard
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "KBExtensionAppLauncher.h"
|
||||||
|
#import <objc/message.h>
|
||||||
|
|
||||||
|
@implementation KBExtensionAppLauncher
|
||||||
|
|
||||||
|
+ (void)openPrimaryURL:(NSURL * _Nullable)primaryURL
|
||||||
|
fallbackURL:(NSURL * _Nullable)fallbackURL
|
||||||
|
usingInputController:(UIInputViewController *)ivc
|
||||||
|
source:(UIResponder *)source
|
||||||
|
completion:(void (^ _Nullable)(BOOL success))completion {
|
||||||
|
if (!ivc || (!primaryURL && !fallbackURL)) {
|
||||||
|
if (completion) { completion(NO); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保证在主线程回调,避免调用方再做一次 dispatch。
|
||||||
|
void (^finish)(BOOL) = ^(BOOL ok){
|
||||||
|
if (!completion) return;
|
||||||
|
if ([NSThread isMainThread]) {
|
||||||
|
completion(ok);
|
||||||
|
} else {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{ completion(ok); });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NSURL *first = primaryURL ?: fallbackURL;
|
||||||
|
NSURL *second = (first == primaryURL) ? fallbackURL : nil;
|
||||||
|
|
||||||
|
if (!first) {
|
||||||
|
finish(NO);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ivc.extensionContext openURL:first completionHandler:^(BOOL ok) {
|
||||||
|
if (ok) {
|
||||||
|
finish(YES);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (second) {
|
||||||
|
[ivc.extensionContext openURL:second completionHandler:^(BOOL ok2) {
|
||||||
|
if (ok2) {
|
||||||
|
finish(YES);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BOOL bridged = [self p_bridgeFirst:first second:second from:source];
|
||||||
|
finish(bridged);
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
BOOL bridged = [self p_bridgeFirst:first second:nil from:source];
|
||||||
|
finish(bridged);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)openScheme:(NSURL *)scheme
|
||||||
|
usingInputController:(UIInputViewController *)ivc
|
||||||
|
source:(UIResponder *)source
|
||||||
|
completion:(void (^ _Nullable)(BOOL success))completion {
|
||||||
|
[self openPrimaryURL:scheme
|
||||||
|
fallbackURL:nil
|
||||||
|
usingInputController:ivc
|
||||||
|
source:source
|
||||||
|
completion:completion];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private
|
||||||
|
|
||||||
|
// 通过响应链尝试调用 openURL:(等价于原 KBURLOpenBridge 实现)
|
||||||
|
+ (BOOL)p_openURLViaResponder:(NSURL *)url from:(UIResponder *)start {
|
||||||
|
#if KB_URL_BRIDGE_ENABLE
|
||||||
|
if (!url || !start) return NO;
|
||||||
|
SEL sel = NSSelectorFromString(@"openURL:");
|
||||||
|
UIResponder *responder = start;
|
||||||
|
while (responder) {
|
||||||
|
@try {
|
||||||
|
if ([responder respondsToSelector:sel]) {
|
||||||
|
BOOL handled = NO;
|
||||||
|
BOOL (*funcBool)(id, SEL, NSURL *) = (BOOL (*)(id, SEL, NSURL *))objc_msgSend;
|
||||||
|
if (funcBool) {
|
||||||
|
handled = funcBool(responder, sel, url);
|
||||||
|
} else {
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||||
|
[responder performSelector:sel withObject:url];
|
||||||
|
handled = YES;
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
}
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
} @catch (__unused NSException *e) {
|
||||||
|
// ignore and continue
|
||||||
|
}
|
||||||
|
responder = responder.nextResponder;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
#else
|
||||||
|
(void)url; (void)start;
|
||||||
|
return NO;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL)p_bridgeFirst:(NSURL * _Nullable)first
|
||||||
|
second:(NSURL * _Nullable)second
|
||||||
|
from:(UIResponder *)source {
|
||||||
|
BOOL bridged = NO;
|
||||||
|
if (first) {
|
||||||
|
bridged = [self p_openURLViaResponder:first from:source];
|
||||||
|
}
|
||||||
|
if (!bridged && second) {
|
||||||
|
bridged = [self p_openURLViaResponder:second from:source];
|
||||||
|
}
|
||||||
|
return bridged;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
//
|
|
||||||
// KBURLOpenBridge.h
|
|
||||||
// 非公开:通过响应链查找 `openURL:` 选择器,尝试在扩展环境中打开自定义 scheme。
|
|
||||||
// 警告:存在审核风险。默认仅 Debug 启用(见 KB_URL_BRIDGE_ENABLE)。
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
#ifndef KB_URL_BRIDGE_ENABLE
|
|
||||||
#if DEBUG
|
|
||||||
#define KB_URL_BRIDGE_ENABLE 1
|
|
||||||
#else
|
|
||||||
#define KB_URL_BRIDGE_ENABLE 0
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@interface KBURLOpenBridge : NSObject
|
|
||||||
|
|
||||||
/// 尝试通过响应链调用 openURL:(仅在 KB_URL_BRIDGE_ENABLE 为 1 时执行)。
|
|
||||||
/// @param url 自定义 scheme,如 kbkeyboard://settings
|
|
||||||
/// @param start 起始 responder(传 self 或任意视图)
|
|
||||||
/// @return 是否看起来已发起打开动作(不保证一定成功)
|
|
||||||
+ (BOOL)openURLViaResponder:(NSURL *)url from:(UIResponder *)start;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
|
||||||
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
//
|
|
||||||
// KBURLOpenBridge.m
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "KBURLOpenBridge.h"
|
|
||||||
#import <objc/message.h>
|
|
||||||
|
|
||||||
@implementation KBURLOpenBridge
|
|
||||||
|
|
||||||
+ (BOOL)openURLViaResponder:(NSURL *)url from:(UIResponder *)start {
|
|
||||||
#if KB_URL_BRIDGE_ENABLE
|
|
||||||
if (!url || !start) return NO;
|
|
||||||
SEL sel = NSSelectorFromString(@"openURL:");
|
|
||||||
UIResponder *responder = start;
|
|
||||||
while (responder) {
|
|
||||||
@try {
|
|
||||||
if ([responder respondsToSelector:sel]) {
|
|
||||||
// 尽量按签名调用;若失败则回退 performSelector
|
|
||||||
BOOL handled = NO;
|
|
||||||
// 尝试 (BOOL)openURL:(NSURL *)
|
|
||||||
BOOL (*funcBool)(id, SEL, NSURL *) = (BOOL (*)(id, SEL, NSURL *))objc_msgSend;
|
|
||||||
if (funcBool) {
|
|
||||||
handled = funcBool(responder, sel, url);
|
|
||||||
} else {
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
|
||||||
[responder performSelector:sel withObject:url];
|
|
||||||
handled = YES;
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
}
|
|
||||||
return handled;
|
|
||||||
}
|
|
||||||
} @catch (__unused NSException *e) {
|
|
||||||
// ignore and continue
|
|
||||||
}
|
|
||||||
responder = responder.nextResponder;
|
|
||||||
}
|
|
||||||
return NO;
|
|
||||||
#else
|
|
||||||
(void)url; (void)start;
|
|
||||||
return NO;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#import "Masonry.h"
|
#import "Masonry.h"
|
||||||
#import "KBResponderUtils.h" // 统一查找 UIInputViewController 的工具
|
#import "KBResponderUtils.h" // 统一查找 UIInputViewController 的工具
|
||||||
#import "KBHUD.h"
|
#import "KBHUD.h"
|
||||||
#import "KBURLOpenBridge.h"
|
#import "KBExtensionAppLauncher.h"
|
||||||
|
|
||||||
@interface KBFullAccessGuideView ()
|
@interface KBFullAccessGuideView ()
|
||||||
@property (nonatomic, strong) UIControl *backdrop;
|
@property (nonatomic, strong) UIControl *backdrop;
|
||||||
@@ -168,63 +168,20 @@
|
|||||||
// Universal Link(需 AASA/Associated Domains 配置且 KB_UL_BASE 与域名一致)
|
// Universal Link(需 AASA/Associated Domains 配置且 KB_UL_BASE 与域名一致)
|
||||||
NSURL *ul = [NSURL URLWithString:[NSString stringWithFormat:@"%@?src=kb_extension", KB_UL_SETTINGS]];
|
NSURL *ul = [NSURL URLWithString:[NSString stringWithFormat:@"%@?src=kb_extension", KB_UL_SETTINGS]];
|
||||||
|
|
||||||
void (^finish)(BOOL) = ^(BOOL ok){
|
__weak typeof(self) weakSelf = self;
|
||||||
if (ok) { [self dismiss]; }
|
[KBExtensionAppLauncher openPrimaryURL:scheme
|
||||||
else {
|
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];
|
NSString *showInfo = [NSString stringWithFormat:KBLocalized(@"Follow: Settings → General → Keyboard → Keyboards → %@ → Allow Full Access"),AppName];
|
||||||
[KBHUD showInfo:showInfo];
|
[KBHUD showInfo:showInfo];
|
||||||
}
|
}
|
||||||
};
|
}];
|
||||||
|
|
||||||
// 先试 Scheme(更可能被宿主允许直接拉起 App)
|
|
||||||
if (scheme) {
|
|
||||||
[ivc.extensionContext openURL:scheme completionHandler:^(BOOL ok) {
|
|
||||||
if (ok) { finish(YES); return; }
|
|
||||||
if (ul) {
|
|
||||||
[ivc.extensionContext openURL:ul completionHandler:^(BOOL ok2) {
|
|
||||||
if (ok2) { finish(YES); return; }
|
|
||||||
// 兜底:在用户点击触发的场景下,尝试通过响应链调用 openURL:
|
|
||||||
BOOL bridged = NO;
|
|
||||||
@try {
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
|
||||||
bridged = [KBURLOpenBridge openURLViaResponder:scheme from:self];
|
|
||||||
if (!bridged && ul) {
|
|
||||||
bridged = [KBURLOpenBridge openURLViaResponder:ul from:self];
|
|
||||||
}
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
} @catch (__unused NSException *e) { bridged = NO; }
|
|
||||||
finish(bridged);
|
|
||||||
}];
|
|
||||||
} else {
|
|
||||||
// 没有 UL,则直接尝试桥接 Scheme
|
|
||||||
BOOL bridged = NO;
|
|
||||||
@try {
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
|
||||||
bridged = [KBURLOpenBridge openURLViaResponder:scheme from:self];
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
} @catch (__unused NSException *e) { bridged = NO; }
|
|
||||||
finish(bridged);
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 无 scheme 时,直接尝试 UL
|
|
||||||
if (ul) {
|
|
||||||
[ivc.extensionContext openURL:ul completionHandler:^(BOOL ok) {
|
|
||||||
if (ok) { finish(YES); return; }
|
|
||||||
BOOL bridged = NO;
|
|
||||||
@try {
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
|
||||||
bridged = [KBURLOpenBridge openURLViaResponder:ul from:self];
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
} @catch (__unused NSException *e) { bridged = NO; }
|
|
||||||
finish(bridged);
|
|
||||||
}];
|
|
||||||
} else {
|
|
||||||
finish(NO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
#import "KBFullAccessManager.h"
|
#import "KBFullAccessManager.h"
|
||||||
#import "KBSkinManager.h"
|
#import "KBSkinManager.h"
|
||||||
#import "KBAuthManager.h" // 登录态判断(共享钥匙串)
|
#import "KBAuthManager.h" // 登录态判断(共享钥匙串)
|
||||||
#import "KBULBridge.h" // Darwin 通知常量(UL 已处理)
|
#import "KBULBridgeNotification.h" // Darwin 通知常量(UL 已处理)
|
||||||
#import "KBURLOpenBridge.h" // 兜底从扩展侧直接尝试 openURL:
|
#import "KBExtensionAppLauncher.h"
|
||||||
#import "KBStreamTextView.h" // 流式文本视图
|
#import "KBStreamTextView.h" // 流式文本视图
|
||||||
#import "KBStreamOverlayView.h" // 带关闭按钮的流式层
|
#import "KBStreamOverlayView.h" // 带关闭按钮的流式层
|
||||||
#import "KBFunctionTagListView.h"
|
#import "KBFunctionTagListView.h"
|
||||||
@@ -329,16 +329,11 @@ static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/
|
|||||||
if (self.kb_ulHandledFlag) return; // 主 App 已确认处理
|
if (self.kb_ulHandledFlag) return; // 主 App 已确认处理
|
||||||
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@://login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)index, encodedTitle]];
|
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@://login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)index, encodedTitle]];
|
||||||
if (!scheme) return;
|
if (!scheme) return;
|
||||||
[ivc.extensionContext openURL:scheme completionHandler:^(__unused BOOL ok2) {
|
[KBExtensionAppLauncher openScheme:scheme
|
||||||
if (ok2) return;
|
usingInputController:ivc
|
||||||
BOOL bridged = NO;
|
source:self
|
||||||
@try {
|
completion:^(BOOL success) {
|
||||||
#pragma clang diagnostic push
|
if (!success) {
|
||||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
|
||||||
bridged = [KBURLOpenBridge openURLViaResponder:scheme from:self];
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
} @catch (__unused NSException *e) { bridged = NO; }
|
|
||||||
if (!bridged) {
|
|
||||||
[KBHUD showInfo:KBLocalized(@"请切换到主App完成登录")];
|
[KBHUD showInfo:KBLocalized(@"请切换到主App完成登录")];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
@@ -383,29 +378,18 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C
|
|||||||
if (!ul) return;
|
if (!ul) return;
|
||||||
|
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
[ivc.extensionContext openURL:ul completionHandler:^(BOOL ok) {
|
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@@//login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)indexPath.item, encodedTitle]];
|
||||||
if (ok) return; // Universal Link 成功
|
[KBExtensionAppLauncher openPrimaryURL:ul
|
||||||
|
fallbackURL:scheme
|
||||||
// 统一使用主 App 注册的自定义 Scheme
|
usingInputController:ivc
|
||||||
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@@//login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)indexPath.item, encodedTitle]];
|
source:self
|
||||||
[ivc.extensionContext openURL:scheme completionHandler:^(BOOL ok2) {
|
completion:^(BOOL success) {
|
||||||
if (ok2) return;
|
if (!success) {
|
||||||
|
// 两条路都失败:大概率未开完全访问或宿主拦截。统一交由 Manager 引导。
|
||||||
// 兜底:在用户点击触发的场景下,尝试通过响应链调用 openURL:
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
// 以提升在“备忘录”等宿主中的成功率。
|
[[KBFullAccessManager shared] ensureFullAccessOrGuideInView:self];
|
||||||
BOOL bridged = NO;
|
});
|
||||||
@try {
|
}
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
|
||||||
bridged = [KBURLOpenBridge openURLViaResponder:scheme from:self];
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
} @catch (__unused NSException *e) { bridged = NO; }
|
|
||||||
|
|
||||||
if (!bridged) {
|
|
||||||
// 两条路都失败:大概率未开完全访问或宿主拦截。统一交由 Manager 引导。
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{ [[KBFullAccessManager shared] ensureFullAccessOrGuideInView:self]; });
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// KBULBridge.h
|
// KBULBridgeNotification.h
|
||||||
// 通用的 UL/Scheme 拉起桥接常量(App 与键盘扩展共享)
|
// 通用的 UL/Scheme 拉起桥接常量(App 与键盘扩展共享)
|
||||||
//
|
//
|
||||||
// 用途:主 App 在成功处理 Universal Link(如 /ul/login)时,
|
// 用途:主 App 在成功处理 Universal Link(如 /ul/login)时,
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
//
|
//
|
||||||
// KBULBridge.m
|
// KBULBridgeNotification.m
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "KBULBridge.h"
|
#import "KBULBridgeNotification.h"
|
||||||
|
|
||||||
/// Darwin 跨进程通知:UL 已被主 App 处理
|
/// Darwin 跨进程通知:UL 已被主 App 处理
|
||||||
NSString * const KBDarwinULHandled = @"com.loveKey.nyx.ul.opened";
|
NSString * const KBDarwinULHandled = @"com.loveKey.nyx.ul.opened";
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
0459D1B82EBA287900F2D189 /* KBSkinManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0459D1B62EBA287900F2D189 /* KBSkinManager.m */; };
|
0459D1B82EBA287900F2D189 /* KBSkinManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0459D1B62EBA287900F2D189 /* KBSkinManager.m */; };
|
||||||
046131112ECF3A6E00A6FADF /* fense.zip in Resources */ = {isa = PBXBuildFile; fileRef = 046131102ECF3A6E00A6FADF /* fense.zip */; };
|
046131112ECF3A6E00A6FADF /* fense.zip in Resources */ = {isa = PBXBuildFile; fileRef = 046131102ECF3A6E00A6FADF /* fense.zip */; };
|
||||||
046131142ECF454500A6FADF /* KBKeyPreviewView.m in Sources */ = {isa = PBXBuildFile; fileRef = 046131132ECF454500A6FADF /* KBKeyPreviewView.m */; };
|
046131142ECF454500A6FADF /* KBKeyPreviewView.m in Sources */ = {isa = PBXBuildFile; fileRef = 046131132ECF454500A6FADF /* KBKeyPreviewView.m */; };
|
||||||
0477BD952EBAFF4E0055D639 /* KBURLOpenBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BD932EBAFF4E0055D639 /* KBURLOpenBridge.m */; };
|
046131172ED06FC800A6FADF /* KBExtensionAppLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 046131162ED06FC800A6FADF /* KBExtensionAppLauncher.m */; };
|
||||||
0477BDF02EBB76E30055D639 /* HomeSheetVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDEF2EBB76E30055D639 /* HomeSheetVC.m */; };
|
0477BDF02EBB76E30055D639 /* HomeSheetVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDEF2EBB76E30055D639 /* HomeSheetVC.m */; };
|
||||||
0477BDF32EBB7B850055D639 /* KBDirectionIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDF22EBB7B850055D639 /* KBDirectionIndicatorView.m */; };
|
0477BDF32EBB7B850055D639 /* KBDirectionIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDF22EBB7B850055D639 /* KBDirectionIndicatorView.m */; };
|
||||||
0477BDF72EBC63A80055D639 /* KBTestVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDF62EBC63A80055D639 /* KBTestVC.m */; };
|
0477BDF72EBC63A80055D639 /* KBTestVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0477BDF62EBC63A80055D639 /* KBTestVC.m */; };
|
||||||
@@ -93,8 +93,8 @@
|
|||||||
049FB2352EC45C6A00FAB05D /* NetworkStreamHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2342EC45C6A00FAB05D /* NetworkStreamHandler.m */; };
|
049FB2352EC45C6A00FAB05D /* NetworkStreamHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2342EC45C6A00FAB05D /* NetworkStreamHandler.m */; };
|
||||||
049FB23B2EC4766700FAB05D /* KBFunctionTagListView.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2372EC4766700FAB05D /* KBFunctionTagListView.m */; };
|
049FB23B2EC4766700FAB05D /* KBFunctionTagListView.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2372EC4766700FAB05D /* KBFunctionTagListView.m */; };
|
||||||
049FB23C2EC4766700FAB05D /* KBStreamOverlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2392EC4766700FAB05D /* KBStreamOverlayView.m */; };
|
049FB23C2EC4766700FAB05D /* KBStreamOverlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2392EC4766700FAB05D /* KBStreamOverlayView.m */; };
|
||||||
049FB23F2EC4B6EF00FAB05D /* KBULBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB23E2EC4B6EF00FAB05D /* KBULBridge.m */; };
|
049FB23F2EC4B6EF00FAB05D /* KBULBridgeNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB23E2EC4B6EF00FAB05D /* KBULBridgeNotification.m */; };
|
||||||
049FB2402EC4B6EF00FAB05D /* KBULBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB23E2EC4B6EF00FAB05D /* KBULBridge.m */; };
|
049FB2402EC4B6EF00FAB05D /* KBULBridgeNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB23E2EC4B6EF00FAB05D /* KBULBridgeNotification.m */; };
|
||||||
049FB2432EC4BBB700FAB05D /* KBLoginPopView.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2422EC4BBB700FAB05D /* KBLoginPopView.m */; };
|
049FB2432EC4BBB700FAB05D /* KBLoginPopView.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB2422EC4BBB700FAB05D /* KBLoginPopView.m */; };
|
||||||
049FB31D2EC21BCD00FAB05D /* KBMyKeyboardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB31C2EC21BCD00FAB05D /* KBMyKeyboardCell.m */; };
|
049FB31D2EC21BCD00FAB05D /* KBMyKeyboardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 049FB31C2EC21BCD00FAB05D /* KBMyKeyboardCell.m */; };
|
||||||
04A9FE0F2EB481100020DB6D /* KBHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC97082EB31B14007BD342 /* KBHUD.m */; };
|
04A9FE0F2EB481100020DB6D /* KBHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC97082EB31B14007BD342 /* KBHUD.m */; };
|
||||||
@@ -233,8 +233,8 @@
|
|||||||
046131102ECF3A6E00A6FADF /* fense.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = fense.zip; sourceTree = "<group>"; };
|
046131102ECF3A6E00A6FADF /* fense.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = fense.zip; sourceTree = "<group>"; };
|
||||||
046131122ECF454500A6FADF /* KBKeyPreviewView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBKeyPreviewView.h; sourceTree = "<group>"; };
|
046131122ECF454500A6FADF /* KBKeyPreviewView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBKeyPreviewView.h; sourceTree = "<group>"; };
|
||||||
046131132ECF454500A6FADF /* KBKeyPreviewView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKeyPreviewView.m; sourceTree = "<group>"; };
|
046131132ECF454500A6FADF /* KBKeyPreviewView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKeyPreviewView.m; sourceTree = "<group>"; };
|
||||||
0477BD922EBAFF4E0055D639 /* KBURLOpenBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBURLOpenBridge.h; sourceTree = "<group>"; };
|
046131152ED06FC800A6FADF /* KBExtensionAppLauncher.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBExtensionAppLauncher.h; sourceTree = "<group>"; };
|
||||||
0477BD932EBAFF4E0055D639 /* KBURLOpenBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBURLOpenBridge.m; sourceTree = "<group>"; };
|
046131162ED06FC800A6FADF /* KBExtensionAppLauncher.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBExtensionAppLauncher.m; sourceTree = "<group>"; };
|
||||||
0477BDEE2EBB76E30055D639 /* HomeSheetVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeSheetVC.h; sourceTree = "<group>"; };
|
0477BDEE2EBB76E30055D639 /* HomeSheetVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeSheetVC.h; sourceTree = "<group>"; };
|
||||||
0477BDEF2EBB76E30055D639 /* HomeSheetVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeSheetVC.m; sourceTree = "<group>"; };
|
0477BDEF2EBB76E30055D639 /* HomeSheetVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeSheetVC.m; sourceTree = "<group>"; };
|
||||||
0477BDF12EBB7B850055D639 /* KBDirectionIndicatorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBDirectionIndicatorView.h; sourceTree = "<group>"; };
|
0477BDF12EBB7B850055D639 /* KBDirectionIndicatorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBDirectionIndicatorView.h; sourceTree = "<group>"; };
|
||||||
@@ -345,8 +345,8 @@
|
|||||||
049FB2372EC4766700FAB05D /* KBFunctionTagListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBFunctionTagListView.m; sourceTree = "<group>"; };
|
049FB2372EC4766700FAB05D /* KBFunctionTagListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBFunctionTagListView.m; sourceTree = "<group>"; };
|
||||||
049FB2382EC4766700FAB05D /* KBStreamOverlayView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBStreamOverlayView.h; sourceTree = "<group>"; };
|
049FB2382EC4766700FAB05D /* KBStreamOverlayView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBStreamOverlayView.h; sourceTree = "<group>"; };
|
||||||
049FB2392EC4766700FAB05D /* KBStreamOverlayView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBStreamOverlayView.m; sourceTree = "<group>"; };
|
049FB2392EC4766700FAB05D /* KBStreamOverlayView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBStreamOverlayView.m; sourceTree = "<group>"; };
|
||||||
049FB23D2EC4B6EF00FAB05D /* KBULBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBULBridge.h; sourceTree = "<group>"; };
|
049FB23D2EC4B6EF00FAB05D /* KBULBridgeNotification.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBULBridgeNotification.h; sourceTree = "<group>"; };
|
||||||
049FB23E2EC4B6EF00FAB05D /* KBULBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBULBridge.m; sourceTree = "<group>"; };
|
049FB23E2EC4B6EF00FAB05D /* KBULBridgeNotification.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBULBridgeNotification.m; sourceTree = "<group>"; };
|
||||||
049FB2412EC4BBB700FAB05D /* KBLoginPopView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBLoginPopView.h; sourceTree = "<group>"; };
|
049FB2412EC4BBB700FAB05D /* KBLoginPopView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBLoginPopView.h; sourceTree = "<group>"; };
|
||||||
049FB2422EC4BBB700FAB05D /* KBLoginPopView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBLoginPopView.m; sourceTree = "<group>"; };
|
049FB2422EC4BBB700FAB05D /* KBLoginPopView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBLoginPopView.m; sourceTree = "<group>"; };
|
||||||
049FB31B2EC21BCD00FAB05D /* KBMyKeyboardCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBMyKeyboardCell.h; sourceTree = "<group>"; };
|
049FB31B2EC21BCD00FAB05D /* KBMyKeyboardCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBMyKeyboardCell.h; sourceTree = "<group>"; };
|
||||||
@@ -587,8 +587,8 @@
|
|||||||
0477BD942EBAFF4E0055D639 /* Utils */ = {
|
0477BD942EBAFF4E0055D639 /* Utils */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
0477BD922EBAFF4E0055D639 /* KBURLOpenBridge.h */,
|
046131152ED06FC800A6FADF /* KBExtensionAppLauncher.h */,
|
||||||
0477BD932EBAFF4E0055D639 /* KBURLOpenBridge.m */,
|
046131162ED06FC800A6FADF /* KBExtensionAppLauncher.m */,
|
||||||
);
|
);
|
||||||
path = Utils;
|
path = Utils;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -1272,8 +1272,8 @@
|
|||||||
04A9FE192EB892460020DB6D /* KBLocalizationManager.m */,
|
04A9FE192EB892460020DB6D /* KBLocalizationManager.m */,
|
||||||
0459D1B52EBA287900F2D189 /* KBSkinManager.h */,
|
0459D1B52EBA287900F2D189 /* KBSkinManager.h */,
|
||||||
0459D1B62EBA287900F2D189 /* KBSkinManager.m */,
|
0459D1B62EBA287900F2D189 /* KBSkinManager.m */,
|
||||||
049FB23D2EC4B6EF00FAB05D /* KBULBridge.h */,
|
049FB23D2EC4B6EF00FAB05D /* KBULBridgeNotification.h */,
|
||||||
049FB23E2EC4B6EF00FAB05D /* KBULBridge.m */,
|
049FB23E2EC4B6EF00FAB05D /* KBULBridgeNotification.m */,
|
||||||
04D1F6B02EDFF10A00B12345 /* KBSkinInstallBridge.h */,
|
04D1F6B02EDFF10A00B12345 /* KBSkinInstallBridge.h */,
|
||||||
04D1F6B12EDFF10A00B12345 /* KBSkinInstallBridge.m */,
|
04D1F6B12EDFF10A00B12345 /* KBSkinInstallBridge.m */,
|
||||||
);
|
);
|
||||||
@@ -1540,11 +1540,12 @@
|
|||||||
049FB2352EC45C6A00FAB05D /* NetworkStreamHandler.m in Sources */,
|
049FB2352EC45C6A00FAB05D /* NetworkStreamHandler.m in Sources */,
|
||||||
04FC956A2EB05497007BD342 /* KBKeyButton.m in Sources */,
|
04FC956A2EB05497007BD342 /* KBKeyButton.m in Sources */,
|
||||||
04FC95B22EB0B2CC007BD342 /* KBSettingView.m in Sources */,
|
04FC95B22EB0B2CC007BD342 /* KBSettingView.m in Sources */,
|
||||||
|
046131172ED06FC800A6FADF /* KBExtensionAppLauncher.m in Sources */,
|
||||||
049FB23B2EC4766700FAB05D /* KBFunctionTagListView.m in Sources */,
|
049FB23B2EC4766700FAB05D /* KBFunctionTagListView.m in Sources */,
|
||||||
049FB23C2EC4766700FAB05D /* KBStreamOverlayView.m in Sources */,
|
049FB23C2EC4766700FAB05D /* KBStreamOverlayView.m in Sources */,
|
||||||
049FB22F2EC34EB900FAB05D /* KBStreamTextView.m in Sources */,
|
049FB22F2EC34EB900FAB05D /* KBStreamTextView.m in Sources */,
|
||||||
04FC95702EB09516007BD342 /* KBFunctionView.m in Sources */,
|
04FC95702EB09516007BD342 /* KBFunctionView.m in Sources */,
|
||||||
049FB23F2EC4B6EF00FAB05D /* KBULBridge.m in Sources */,
|
049FB23F2EC4B6EF00FAB05D /* KBULBridgeNotification.m in Sources */,
|
||||||
04FC956D2EB054B7007BD342 /* KBKeyboardView.m in Sources */,
|
04FC956D2EB054B7007BD342 /* KBKeyboardView.m in Sources */,
|
||||||
04FC95672EB0546C007BD342 /* KBKey.m in Sources */,
|
04FC95672EB0546C007BD342 /* KBKey.m in Sources */,
|
||||||
A1B2C3F42EB35A9900000001 /* KBFullAccessGuideView.m in Sources */,
|
A1B2C3F42EB35A9900000001 /* KBFullAccessGuideView.m in Sources */,
|
||||||
@@ -1552,7 +1553,6 @@
|
|||||||
A1B2C4002EB4A0A100000003 /* KBAuthManager.m in Sources */,
|
A1B2C4002EB4A0A100000003 /* KBAuthManager.m in Sources */,
|
||||||
04A9FE132EB4D0D20020DB6D /* KBFullAccessManager.m in Sources */,
|
04A9FE132EB4D0D20020DB6D /* KBFullAccessManager.m in Sources */,
|
||||||
A1B2C4202EB4B7A100000001 /* KBKeyboardPermissionManager.m in Sources */,
|
A1B2C4202EB4B7A100000001 /* KBKeyboardPermissionManager.m in Sources */,
|
||||||
0477BD952EBAFF4E0055D639 /* KBURLOpenBridge.m in Sources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -1597,7 +1597,7 @@
|
|||||||
04FC95D82EB1EA16007BD342 /* BaseCell.m in Sources */,
|
04FC95D82EB1EA16007BD342 /* BaseCell.m in Sources */,
|
||||||
0477BDF72EBC63A80055D639 /* KBTestVC.m in Sources */,
|
0477BDF72EBC63A80055D639 /* KBTestVC.m in Sources */,
|
||||||
04122F7E2EC5FC5500EF7AB3 /* KBJfPayCell.m in Sources */,
|
04122F7E2EC5FC5500EF7AB3 /* KBJfPayCell.m in Sources */,
|
||||||
049FB2402EC4B6EF00FAB05D /* KBULBridge.m in Sources */,
|
049FB2402EC4B6EF00FAB05D /* KBULBridgeNotification.m in Sources */,
|
||||||
04FC95C92EB1E4C9007BD342 /* BaseNavigationController.m in Sources */,
|
04FC95C92EB1E4C9007BD342 /* BaseNavigationController.m in Sources */,
|
||||||
048908DD2EBF67EB00FABA60 /* KBSearchResultVC.m in Sources */,
|
048908DD2EBF67EB00FABA60 /* KBSearchResultVC.m in Sources */,
|
||||||
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */,
|
047C65102EBCA8DD0035E841 /* HomeRankContentVC.m in Sources */,
|
||||||
|
|||||||
@@ -6,29 +6,27 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
#import "KBPermissionViewController.h"
|
//#import "KBPermissionViewController.h"
|
||||||
#import <AFNetworking/AFNetworking.h>
|
#import <AFNetworking/AFNetworking.h>
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
#import <Bugly/Bugly.h>
|
#import <Bugly/Bugly.h>
|
||||||
#endif
|
#endif
|
||||||
#import "BaseTabBarController.h"
|
#import "BaseTabBarController.h"
|
||||||
#import "LoginViewController.h"
|
//#import "LoginViewController.h"
|
||||||
#import "KBLoginSheetViewController.h"
|
//#import "KBLoginSheetViewController.h"
|
||||||
#import "AppleSignInManager.h"
|
//#import "AppleSignInManager.h"
|
||||||
#import <objc/message.h>
|
//#import <objc/message.h>
|
||||||
#import "KBULBridge.h" // Darwin 通知常量:用于通知扩展“UL已处理”
|
#import "KBULBridgeNotification.h" // Darwin 通知常量:用于通知扩展“UL已处理”
|
||||||
#import "LSTPopView.h"
|
#import "LSTPopView.h"
|
||||||
#import "KBLoginPopView.h"
|
#import "KBLoginPopView.h"
|
||||||
#import "IAPVerifyTransactionObj.h"
|
#import "IAPVerifyTransactionObj.h"
|
||||||
#import "FGIAPManager.h"
|
#import "FGIAPManager.h"
|
||||||
#import "KBSexSelVC.h"
|
#import "KBSexSelVC.h"
|
||||||
#import <SystemConfiguration/CaptiveNetwork.h>
|
|
||||||
#import <CoreTelephony/CTCellularData.h>
|
|
||||||
|
|
||||||
// 注意:用于判断系统已启用本输入法扩展的 bundle id 需与扩展 target 的
|
// 注意:用于判断系统已启用本输入法扩展的 bundle id 需与扩展 target 的
|
||||||
// PRODUCT_BUNDLE_IDENTIFIER 完全一致。
|
// PRODUCT_BUNDLE_IDENTIFIER 完全一致。
|
||||||
// 当前工程的 CustomKeyboard target 为 com.loveKey.nyx.CustomKeyboard
|
// 当前工程的 CustomKeyboard target 为 com.loveKey.nyx.CustomKeyboard
|
||||||
static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomKeyboard";
|
//static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomKeyboard";
|
||||||
|
|
||||||
@implementation AppDelegate
|
@implementation AppDelegate
|
||||||
|
|
||||||
@@ -143,6 +141,10 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
|||||||
} else if ([host isEqualToString:@"settings"]) { // kbkeyboard://settings
|
} else if ([host isEqualToString:@"settings"]) { // kbkeyboard://settings
|
||||||
[self kb_openAppSettings];
|
[self kb_openAppSettings];
|
||||||
return YES;
|
return YES;
|
||||||
|
}else if ([host isEqualToString:@"recharge"]) { // kbkeyboard://settings
|
||||||
|
// [self kb_openAppSettings];
|
||||||
|
[KBHUD showInfo:@"去充值"];
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -244,26 +246,27 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
|||||||
// [PublicObj saveNetReachability:@"wwan"];
|
// [PublicObj saveNetReachability:@"wwan"];
|
||||||
}else{
|
}else{
|
||||||
// [PublicObj saveNetReachability:@"unknown"];
|
// [PublicObj saveNetReachability:@"unknown"];
|
||||||
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL KBIsKeyboardEnabled(void) {
|
//static BOOL KBIsKeyboardEnabled(void) {
|
||||||
for (UITextInputMode *mode in [UITextInputMode activeInputModes]) {
|
// for (UITextInputMode *mode in [UITextInputMode activeInputModes]) {
|
||||||
NSString *identifier = nil;
|
// NSString *identifier = nil;
|
||||||
@try {
|
// @try {
|
||||||
identifier = [mode valueForKey:@"identifier"]; // not a public API
|
// identifier = [mode valueForKey:@"identifier"]; // not a public API
|
||||||
} @catch (__unused NSException *e) {
|
// } @catch (__unused NSException *e) {
|
||||||
identifier = nil;
|
// identifier = nil;
|
||||||
}
|
// }
|
||||||
if ([identifier isKindOfClass:[NSString class]] &&
|
// if ([identifier isKindOfClass:[NSString class]] &&
|
||||||
[identifier rangeOfString:kKBKeyboardExtensionBundleId].location != NSNotFound) {
|
// [identifier rangeOfString:kKBKeyboardExtensionBundleId].location != NSNotFound) {
|
||||||
return YES;
|
// return YES;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return NO;
|
// return NO;
|
||||||
}
|
//}
|
||||||
|
|
||||||
#pragma mark - Network check & alert
|
#pragma mark - Network check & alert
|
||||||
|
|
||||||
@@ -306,86 +309,4 @@ static BOOL KBIsKeyboardEnabled(void) {
|
|||||||
[rootVC presentViewController:alert animated:YES completion:nil];
|
[rootVC presentViewController:alert animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
///*
|
|
||||||
// 获取网络权限状态
|
|
||||||
// */
|
|
||||||
//- (void)networkStatus:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
||||||
// //2.根据权限执行相应的交互
|
|
||||||
// CTCellularData *cellularData = [[CTCellularData alloc] init];
|
|
||||||
// /*
|
|
||||||
// 此函数会在网络权限改变时再次调用
|
|
||||||
// */
|
|
||||||
// cellularData.cellularDataRestrictionDidUpdateNotifier = ^(CTCellularDataRestrictedState state) {
|
|
||||||
// switch (state) {
|
|
||||||
// case kCTCellularDataRestricted:
|
|
||||||
//
|
|
||||||
// NSLog(@"Restricted");
|
|
||||||
// //2.1权限关闭的情况下 再次请求网络数据会弹出设置网络提示
|
|
||||||
//
|
|
||||||
// break;
|
|
||||||
// case kCTCellularDataNotRestricted:
|
|
||||||
//
|
|
||||||
// NSLog(@"NotRestricted");
|
|
||||||
// //2.2已经开启网络权限 监听网络状态
|
|
||||||
// [self addReachabilityManager:application didFinishLaunchingWithOptions:launchOptions];
|
|
||||||
// break;
|
|
||||||
// case kCTCellularDataRestrictedStateUnknown:
|
|
||||||
//
|
|
||||||
// NSLog(@"Unknown");
|
|
||||||
//
|
|
||||||
// break;
|
|
||||||
//
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// 实时检查当前网络状态
|
|
||||||
// */
|
|
||||||
//- (void)addReachabilityManager:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
||||||
// AFNetworkReachabilityManager *afNetworkReachabilityManager = [AFNetworkReachabilityManager sharedManager];
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// [afNetworkReachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
|
||||||
// switch (status) {
|
|
||||||
// case AFNetworkReachabilityStatusNotReachable:{
|
|
||||||
// NSLog(@"网络不通:%@",@(status) );
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// case AFNetworkReachabilityStatusReachableViaWiFi:{
|
|
||||||
// NSLog(@"网络通过WIFI连接:%@",@(status));
|
|
||||||
//
|
|
||||||
// [self getInfo_application:application didFinishLaunchingWithOptions:launchOptions];
|
|
||||||
//
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// case AFNetworkReachabilityStatusReachableViaWWAN:{
|
|
||||||
// NSLog(@"网络通过无线连接:%@",@(status) );
|
|
||||||
//
|
|
||||||
// [self getInfo_application:application didFinishLaunchingWithOptions:launchOptions];
|
|
||||||
//
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }];
|
|
||||||
//
|
|
||||||
// [afNetworkReachabilityManager startMonitoring]; //开启网络监视器;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
////把以前写在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions里面的一些初始化操作放在该方法
|
|
||||||
//- (void)getInfo_application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
||||||
//
|
|
||||||
//// [self.updateBusiness checkUpdateWithBothApi];//检查app更新
|
|
||||||
//
|
|
||||||
////发送通知给APP首屏页面,让其有网络时重新请求
|
|
||||||
// [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil];
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user