VisionWallPaperOffline-8-19/HDwallpaper/AppDelegate.m
2024-07-23 15:14:59 +08:00

128 lines
5.3 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// AppDelegate.m
#import "AppDelegate.h"
#import "AWM_OnePageViewController.h"
#import "AWM_HotViewController.h"
#import "AWM_ditViewController.h"
#import "AWM_ForMyViewController.h"
#import "AWM_WallPapaerADManager.h"
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/ASIdentifierManager.h>
#import "AWM_NetManager.h"
@interface AppDelegate ()
@property (nonatomic,strong) NSTimer *attTimer;
@end
@implementation AppDelegate
//检查idfa的att弹框
- (void)checkATT{
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
// 获取到权限后依然使用老方法获取idfa
if(status == ATTrackingManagerAuthorizationStatusNotDetermined) {
if(self.attTimer == nil) {
self.attTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(checkATT) userInfo:nil repeats:YES];
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
if (status != ATTrackingManagerAuthorizationStatusNotDetermined) {
NSLog(@"用户已做出选择");
[self invalidATTTimer];
}
else {
NSLog(@"用户未做出选择,可能是弹框未弹出...");
}
}];
}
}
else{
[self invalidATTTimer];
}
}];
}
-(void)invalidATTTimer{
if( _attTimer ){
[_attTimer invalidate];
}
_attTimer = nil;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AWM_NetManager requestRemoteIp];
[[AWM_WallPapaerADManager shareInstance] configureAD];
[self checkATT];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[AWM_NetManager uploadAD_Start];
[self.window makeKeyAndVisible];
[[AWM_WallPapaerADManager shareInstance] showFirstOpenAD:^(NSInteger actionType) {
[self configureRootVC];
} window:self.window];
return YES;
}
- (void)configureRootVC {
NSString *tab1 = KLS(@"tab1", @"A friendly greeting");
NSString *tab2 = KLS(@"tab2", @"A friendly greeting");
NSString *tab3 = KLS(@"tab3", @"A friendly greeting");
NSString *tab4 = KLS(@"tab4", @"A friendly greeting");
NSString *tab11 = KLS(@"tab11", @"A friendly greeting");
NSString *tab22 = KLS(@"tab22", @"A friendly greeting");
NSString *tab33 = KLS(@"tab33", @"A friendly greeting");
NSString *tab44 = KLS(@"tab44", @"A friendly greeting");
AWM_OnePageViewController *wpHome = [[AWM_OnePageViewController alloc] init];
wpHome.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:tab1] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:tab11] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
UINavigationController *wpHomeNV = [[UINavigationController alloc] initWithRootViewController:wpHome];
AWM_HotViewController *wpHot = [[AWM_HotViewController alloc] init];
wpHot.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:tab2] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:tab22] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
UINavigationController *wpHotNV = [[UINavigationController alloc] initWithRootViewController:wpHot];
AWM_ditViewController *wpEdit = [[AWM_ditViewController alloc] init];
wpEdit.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:tab3] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:tab33] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
UINavigationController *wpEditNV = [[UINavigationController alloc] initWithRootViewController:wpEdit];
AWM_ForMyViewController *wpMy = [[AWM_ForMyViewController alloc] init];
wpMy.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:tab4] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:tab44] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
UINavigationController *wpMyNV = [[UINavigationController alloc] initWithRootViewController:wpMy];
UITabBarController *tb = [[UITabBarController alloc] init];
tb.tabBar.backgroundColor = WP_COLOR_WITH_HEX(0xFFFFFF);
tb.tabBar.tintColor = [UIColor orangeColor];
UITabBarAppearance *skappearance = [[UITabBarAppearance alloc] init];
skappearance.backgroundColor = WP_COLOR_WITH_HEX(0x6B77F2);
tb.tabBar.standardAppearance = skappearance;
tb.viewControllers = @[wpHomeNV,wpHotNV,wpEditNV,wpMyNV];
tb.selectedIndex = 0;
self.window.rootViewController = tb;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[[AWM_WallPapaerADManager shareInstance] showOpenAD];
}
- (NSMutableArray *)saveImages{
if (!_saveImages) {
_saveImages = [[NSMutableArray alloc] init];
}
return _saveImages;
}
@end