From 0585d1e9e6bf6285bfb53a02ddcd364ac09539de Mon Sep 17 00:00:00 2001 From: eggmanQQQ <3671373519@qq.com> Date: Wed, 12 Jun 2024 11:23:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=BC=98=E5=8C=96=EF=BC=9A?= =?UTF-8?q?=201.=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=202.=20=E4=BC=98=E5=8C=96=E5=86=B7=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E7=9A=84=E5=8A=A0=E8=BD=BD=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YuMi/Appdelegate/AppDelegate+ThirdConfig.m | 108 ++++++++++----------- YuMi/Appdelegate/AppDelegate.m | 74 ++++++++------ 2 files changed, 97 insertions(+), 85 deletions(-) diff --git a/YuMi/Appdelegate/AppDelegate+ThirdConfig.m b/YuMi/Appdelegate/AppDelegate+ThirdConfig.m index e6fd28d9..80ad99c2 100644 --- a/YuMi/Appdelegate/AppDelegate+ThirdConfig.m +++ b/YuMi/Appdelegate/AppDelegate+ThirdConfig.m @@ -36,47 +36,42 @@ UIKIT_EXTERN NSString * adImageName; @implementation AppDelegate (ThirdConfig) - /// 初始化一些第三方配置 -- (void)initThirdConfig { +- (void)initThirdConfig{ [self configShareSDK]; [self configNIMSDK]; - [self initEmojiData]; [self configAdjust]; [self configBugly]; [self registerNot]; + [self initEmojiData]; [self setLanguage]; } + -(void)setLanguage{ - + UISemanticContentAttribute attribute = UISemanticContentAttributeForceLeftToRight; if (isMSRTL()) { - [UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft; - [UISearchBar appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft; - - - } else { - [UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceLeftToRight; - [UISearchBar appearance].semanticContentAttribute = UISemanticContentAttributeForceLeftToRight; - - + attribute = UISemanticContentAttributeForceRightToLeft; } + + [UIView appearance].semanticContentAttribute = attribute; + [UISearchBar appearance].semanticContentAttribute = attribute; } + -(void)registerNot{ if (@available(iOS 10.0, *)) { - UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; - [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) { - if (granted) { - [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { - if (settings.authorizationStatus == UNAuthorizationStatusAuthorized){ - dispatch_async(dispatch_get_main_queue(), ^{ - [[UIApplication sharedApplication] registerForRemoteNotifications]; - }); - } - }]; + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) { + if (granted) { + [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { + if (settings.authorizationStatus == UNAuthorizationStatusAuthorized){ + dispatch_async(dispatch_get_main_queue(), ^{ + [[UIApplication sharedApplication] registerForRemoteNotifications]; + }); } }]; } - + }]; + } } /** @@ -112,10 +107,7 @@ UIKIT_EXTERN NSString * adImageName; #else option.apnsCername = @"newPiko"; #endif - - - [[NIMSDK sharedSDK] registerWithOption:option]; // NIM SDK初始化 @@ -148,6 +140,7 @@ UIKIT_EXTERN NSString * adImageName; #endif [Adjust appDidLaunch:adjustConfig]; } + - (void)configShareSDK { [PILineLoginManager registerLine]; @@ -157,11 +150,10 @@ UIKIT_EXTERN NSString * adImageName; // [platformsRegister setupFacebookWithAppkey:@"1266232494209868" appSecret:@"c9b170b383f8be9cdf118823b8632821" displayName:YMLocalizedString(@"AppDelegate_ThirdConfig0")]; [platformsRegister setupLineAuthType:SSDKAuthorizeTypeBoth]; }]; + NSString *isUpload = [[NSUserDefaults standardUserDefaults]valueForKey:@"kMobLinkUploadPrivacy"]; if (isUpload == nil){ - [MobSDK uploadPrivacyPermissionStatus:YES onResult:^(BOOL success) { - - }]; + [MobSDK uploadPrivacyPermissionStatus:YES onResult:nil]; [[NSUserDefaults standardUserDefaults] setValue:@"YES" forKey:@"kMobLinkUploadPrivacy"]; [[NSUserDefaults standardUserDefaults] synchronize]; } @@ -169,22 +161,24 @@ UIKIT_EXTERN NSString * adImageName; #pragma mark - 表情 - (void)initEmojiData { - NSArray * dicArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"emoji" ofType:@"plist"]]; - NSDictionary * dic = [dicArray firstObject]; - NSArray * emojiArray = dic[@"data"]; - NSMutableArray * array = [NSMutableArray array]; - for (int i = 0; i < emojiArray.count; i++) { - NSDictionary * dic = [emojiArray objectAtIndex:i]; - UIImage * image = [UIImage imageNamed:dic[@"file"]]; - QEmotion * info = [[QEmotion alloc] init]; - info.identifier = dic[@"id"]; - info.image = image; - info.displayName = dic[@"tag"]; - [array addObject:info]; - } - //在这里强烈建议先预加载一下表情 - QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper]; - faceManager.emotionArray = array; + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + NSArray * dicArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"emoji" ofType:@"plist"]]; + NSDictionary * dic = [dicArray firstObject]; + NSArray * emojiArray = dic[@"data"]; + NSMutableArray * array = [NSMutableArray array]; + for (int i = 0; i < emojiArray.count; i++) { + NSDictionary * dic = [emojiArray objectAtIndex:i]; + UIImage * image = [UIImage imageNamed:dic[@"file"]]; + QEmotion * info = [[QEmotion alloc] init]; + info.identifier = dic[@"id"]; + info.image = image; + info.displayName = dic[@"tag"]; + [array addObject:info]; + } + //在这里强烈建议先预加载一下表情 + QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper]; + faceManager.emotionArray = array; + }); } #pragma mark - 广告 @@ -195,22 +189,21 @@ UIKIT_EXTERN NSString * adImageName; - (void)setupLaunchADView { NSUserDefaults * kUserDefaults = NSUserDefaults.standardUserDefaults; // 判断沙盒中是否存在广告图片,如果存在,直接显示 - NSString *filePath = [XPAdImageTool.shareImageTool getFilePathWithImageName:[kUserDefaults valueForKey:adImageName]]; + NSString *adName = [kUserDefaults stringForKey:adImageName]; + NSString *filePath = [XPAdImageTool.shareImageTool getFilePathWithImageName:adName]; BOOL isExist = [XPAdImageTool.shareImageTool isFileExistWithFilePath:filePath]; - NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; - if ([userDefault integerForKey:@"adShow"]) { - [userDefault setInteger:[userDefault integerForKey:@"adShow"]+1 forKey:@"adShow"]; + if ([kUserDefaults integerForKey:@"adShow"]) { + [kUserDefaults setInteger:[kUserDefaults integerForKey:@"adShow"]+1 + forKey:@"adShow"]; } else { - [userDefault setInteger:1 forKey:@"adShow"]; + [kUserDefaults setInteger:1 forKey:@"adShow"]; } if (isExist) {// 图片存在 - - if ([userDefault integerForKey:@"adShow"] > 4) { + if ([kUserDefaults integerForKey:@"adShow"] > 4) { @kWeakify(self); - NSString *imageName = [kUserDefaults valueForKey:adImageName]; - AdvertiseModel *info = [XPAdImageTool.shareImageTool getAdInfoFromCacheInMainWith:imageName]; + AdvertiseModel *info = [XPAdImageTool.shareImageTool getAdInfoFromCacheInMainWith:adName]; XPAdvertiseView *advertiseView = [[XPAdvertiseView alloc] initWithFrame:self.window.bounds]; advertiseView.filePath = filePath; advertiseView.dismissHandler = ^(BOOL shouldJump) { @@ -219,9 +212,8 @@ UIKIT_EXTERN NSString * adImageName; return; } dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self performSelectorOnMainThread:@selector(advertiseJumpHandleWithInfo:) withObject:info waitUntilDone:NO]; - }); - + [self advertiseJumpHandleWithInfo:info]; + }); }; [advertiseView show]; } diff --git a/YuMi/Appdelegate/AppDelegate.m b/YuMi/Appdelegate/AppDelegate.m index 04fbfe05..4ba89197 100644 --- a/YuMi/Appdelegate/AppDelegate.m +++ b/YuMi/Appdelegate/AppDelegate.m @@ -5,15 +5,16 @@ // Created by admin on 2023/3/9. // + +#import "AppDelegate.h" +#import #import #import -#import "AppDelegate.h" +#import #import "TabbarViewController.h" #import "BaseNavigationController.h" #import "AppDelegate+ThirdConfig.h" #import -#import -#import #import #import "ClientConfig.h" #import @@ -35,35 +36,54 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - - AccountModel *accountModel = [[AccountInfoStorage instance] getCurrentAccountInfo]; - if (accountModel == nil || accountModel.uid == nil || accountModel.access_token == nil) { - XPLoginViewController *lvc = [[XPLoginViewController alloc] init]; - BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc]; - nav.modalPresentationStyle = UIModalPresentationFullScreen; - self.window.rootViewController = nav; - }else{ - TabbarViewController *vc = [[TabbarViewController alloc] init]; - BaseNavigationController *bnc = [[BaseNavigationController alloc] initWithRootViewController:vc]; - self.window.rootViewController = bnc; - } - - [self.window makeKeyAndVisible]; - ///设置广告页 - [self setupLaunchADView]; ///初始化一些 sdk配置 - [self initThirdConfig]; - // 只有同意过了隐私协议 才初始化 - if ([[NSUserDefaults standardUserDefaults] objectForKey:@"kYouMinumbernnagna"]) { - ///初始化友盟 - [UMConfigure initWithAppkey:@"6434c6dfd64e686139618269" channel:@"appstore"]; - } + [self initThirdConfig]; + [self initUM:application launchOptions:launchOptions]; + + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + [self.window makeKeyAndVisible]; + + [self loadMainPage]; + [self setupLaunchADView]; + + return YES; +} + +- (void)initUM:(UIApplication *)application + launchOptions:(NSDictionary *)launchOptions { + // 只有同意过了隐私协议 才初始化 + if ([[NSUserDefaults standardUserDefaults] objectForKey:@"kYouMinumbernnagna"]) { + ///初始化友盟 + [UMConfigure initWithAppkey:@"6434c6dfd64e686139618269" + channel:@"appstore"]; + } [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; [FIRApp configure]; [MobLink setDelegate:self]; +} - return YES; +- (void)loadMainPage { + AccountModel *accountModel = [[AccountInfoStorage instance] getCurrentAccountInfo]; + if (accountModel == nil || + accountModel.uid == nil || + accountModel.access_token == nil) { + [self toLoginPage]; + }else{ + [self toHomeTabbarPage]; + } +} + +- (void)toLoginPage { + XPLoginViewController *lvc = [[XPLoginViewController alloc] init]; + BaseNavigationController * navigationController = [[BaseNavigationController alloc] initWithRootViewController:lvc]; + navigationController.modalPresentationStyle = UIModalPresentationFullScreen; + self.window.rootViewController = navigationController; +} + +- (void)toHomeTabbarPage { + TabbarViewController *vc = [[TabbarViewController alloc] init]; + BaseNavigationController *navigationController = [[BaseNavigationController alloc] initWithRootViewController:vc]; + self.window.rootViewController = navigationController; } - (void)IMLSDKWillRestoreScene:(MLSDKScene *)scene