keep edit
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// YUMI
|
||||
//
|
||||
|
||||
|
||||
// Created by admin on 2023/3/9.
|
||||
//
|
||||
|
||||
|
||||
#import "AppDelegate.h"
|
||||
@@ -40,9 +37,9 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
|
||||
// MARK: - Helper Methods
|
||||
|
||||
/// 获取 keyWindow(iOS 13+ 兼容)
|
||||
|
||||
- (UIWindow *)getKeyWindow {
|
||||
// iOS 13+ 使用 connectedScenes 获取 window
|
||||
|
||||
if (@available(iOS 13.0, *)) {
|
||||
for (UIWindowScene *scene in [UIApplication sharedApplication].connectedScenes) {
|
||||
if (scene.activationState == UISceneActivationStateForegroundActive) {
|
||||
@@ -51,13 +48,13 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
return window;
|
||||
}
|
||||
}
|
||||
// 如果没有 keyWindow,返回第一个 window
|
||||
|
||||
return scene.windows.firstObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// iOS 13 以下,使用旧方法(已废弃但仍然可用)
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
return [UIApplication sharedApplication].keyWindow;
|
||||
@@ -74,44 +71,44 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
}else{
|
||||
[self toHomeTabbarPage];
|
||||
|
||||
// 延迟检查专属颜色(等待 window 初始化完成)
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self checkAndShowSignatureColorGuide];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// 检查并显示专属颜色引导页
|
||||
|
||||
- (void)checkAndShowSignatureColorGuide {
|
||||
UIWindow *keyWindow = [self getKeyWindow];
|
||||
if (!keyWindow) return;
|
||||
|
||||
BOOL hasSignatureColor = [EPEmotionColorStorage hasUserSignatureColor];
|
||||
|
||||
#if DEBUG
|
||||
// Debug 环境:总是显示引导页
|
||||
NSLog(@"[AppDelegate] Debug 模式:显示专属颜色引导页(已有颜色: %@)", hasSignatureColor ? @"YES" : @"NO");
|
||||
//#if DEBUG
|
||||
//
|
||||
// NSLog(@"[AppDelegate] Debug 模式:显示专属颜色引导页(已有颜色: %@)", hasSignatureColor ? @"YES" : @"NO");
|
||||
//
|
||||
// EPSignatureColorGuideView *guideView = [[EPSignatureColorGuideView alloc] init];
|
||||
//
|
||||
//
|
||||
// guideView.onColorConfirmed = ^(NSString *hexColor) {
|
||||
// [EPEmotionColorStorage saveUserSignatureColor:hexColor];
|
||||
// NSLog(@"[AppDelegate] 用户选择专属颜色: %@", hexColor);
|
||||
// };
|
||||
//
|
||||
//
|
||||
// if (hasSignatureColor) {
|
||||
// guideView.onSkipTapped = ^{
|
||||
// NSLog(@"[AppDelegate] 用户跳过专属颜色选择");
|
||||
// };
|
||||
// }
|
||||
//
|
||||
//
|
||||
// [guideView showInWindow:keyWindow showSkipButton:hasSignatureColor];
|
||||
//
|
||||
//#else
|
||||
|
||||
EPSignatureColorGuideView *guideView = [[EPSignatureColorGuideView alloc] init];
|
||||
|
||||
// 设置颜色确认回调
|
||||
guideView.onColorConfirmed = ^(NSString *hexColor) {
|
||||
[EPEmotionColorStorage saveUserSignatureColor:hexColor];
|
||||
NSLog(@"[AppDelegate] 用户选择专属颜色: %@", hexColor);
|
||||
};
|
||||
|
||||
// 如果已有颜色,设置 Skip 回调
|
||||
if (hasSignatureColor) {
|
||||
guideView.onSkipTapped = ^{
|
||||
NSLog(@"[AppDelegate] 用户跳过专属颜色选择");
|
||||
};
|
||||
}
|
||||
|
||||
// 显示引导页,已有颜色时显示 Skip 按钮
|
||||
[guideView showInWindow:keyWindow showSkipButton:hasSignatureColor];
|
||||
|
||||
#else
|
||||
// Release 环境:仅在未设置专属颜色时显示
|
||||
if (!hasSignatureColor) {
|
||||
EPSignatureColorGuideView *guideView = [[EPSignatureColorGuideView alloc] init];
|
||||
guideView.onColorConfirmed = ^(NSString *hexColor) {
|
||||
@@ -120,11 +117,11 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
};
|
||||
[guideView showInWindow:keyWindow];
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
}
|
||||
|
||||
- (void)toLoginPage {
|
||||
// 使用新的 Swift 登录页面
|
||||
|
||||
EPLoginViewController *lvc = [[EPLoginViewController alloc] init];
|
||||
BaseNavigationController *navigationController =
|
||||
[[BaseNavigationController alloc] initWithRootViewController:lvc];
|
||||
@@ -159,10 +156,10 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
|
||||
case ATTrackingManagerAuthorizationStatusAuthorized:
|
||||
break;
|
||||
case ATTrackingManagerAuthorizationStatusNotDetermined: {
|
||||
// NSLog(@"用户未做选择或未弹窗IDFA");
|
||||
//请求弹出用户授权框,只会在程序运行是弹框1次,除非卸载app重装,通地图、相机等权限弹框一样
|
||||
|
||||
|
||||
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
|
||||
// NSLog(@"app追踪IDFA权限:%lu",(unsigned long)status);
|
||||
|
||||
}];
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user