1
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#import "KBLoginPopView.h"
|
||||
#import "IAPVerifyTransactionObj.h"
|
||||
#import "FGIAPManager.h"
|
||||
#import "KBSexSelVC.h"
|
||||
// 注意:用于判断系统已启用本输入法扩展的 bundle id 需与扩展 target 的
|
||||
// PRODUCT_BUNDLE_IDENTIFIER 完全一致。
|
||||
// 当前工程的 CustomKeyboard target 为 com.loveKey.nyx.CustomKeyboard
|
||||
@@ -32,11 +33,21 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// 1. 配置内购服务
|
||||
[[FGIAPManager shared] setConfigureWith:[IAPVerifyTransactionObj new]];
|
||||
[self setupRootVC];
|
||||
|
||||
// 首次安装先进入性别选择页;点击 Skip 或确认后再进入主 TabBar
|
||||
BOOL hasShownSexVC = [[NSUserDefaults standardUserDefaults] boolForKey:KBSexSelectShownKey];
|
||||
if (hasShownSexVC) {
|
||||
[self setupRootVC];
|
||||
} else {
|
||||
[self setupSexSelectRootVC];
|
||||
}
|
||||
|
||||
// 主工程默认开启网络总开关(键盘扩展仍需用户允许完全访问后再行开启)
|
||||
[KBNetworkManager shared].enabled = YES;
|
||||
/// 获取网络权限
|
||||
[self getNetJudge];
|
||||
/// 触发一次简单网络请求,用于拉起系统的蜂窝数据权限弹窗
|
||||
[self kb_fireStartupNetworkRequest];
|
||||
|
||||
#if !DEBUG
|
||||
/// Bugly
|
||||
@@ -61,6 +72,24 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
||||
self.window.rootViewController = vc;
|
||||
}
|
||||
|
||||
/// 首次安装时,展示性别选择页作为根控制器
|
||||
- (void)setupSexSelectRootVC {
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.backgroundColor = [UIColor whiteColor];
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
KBSexSelVC *sexVC = [KBSexSelVC new];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
sexVC.didFinishSelectBlock = ^{
|
||||
// 记录已经展示过性别选择页,下次启动直接进 TabBar
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:KBSexSelectShownKey];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
// 切换根控制器到主 TabBar
|
||||
[weakSelf setupRootVC];
|
||||
};
|
||||
self.window.rootViewController = sexVC;
|
||||
}
|
||||
|
||||
#pragma mark - Permission presentation
|
||||
|
||||
|
||||
@@ -172,6 +201,24 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
||||
// 该逻辑已迁移到 KBGuideVC,保留占位以兼容旧调用,但不再执行任何操作
|
||||
}
|
||||
|
||||
/// 使用系统网络栈发起一次简单请求(例如拉起蜂窝数据权限弹窗)。
|
||||
/// 说明:只要真正访问网络,系统在需要时就会弹出“是否允许使用蜂窝数据”等提示。
|
||||
- (void)kb_fireStartupNetworkRequest {
|
||||
NSURL *url = [NSURL URLWithString:@"https://www.apple.com"];
|
||||
if (!url) { return; }
|
||||
|
||||
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
|
||||
NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
|
||||
NSURLSessionDataTask *task = [session dataTaskWithURL:url
|
||||
completionHandler:^(NSData * _Nullable data,
|
||||
NSURLResponse * _Nullable response,
|
||||
NSError * _Nullable error) {
|
||||
// 回到主线程弹出一个简单提示,证明网络请求已经发起
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
});
|
||||
}];
|
||||
[task resume];
|
||||
}
|
||||
|
||||
|
||||
-(void)getNetJudge {
|
||||
|
||||
Reference in New Issue
Block a user