Translate_offine/HD wallpaper/AppDelegate.m
2024-07-03 19:56:37 +08:00

115 lines
4.7 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 "WPOnePageViewController.h"
#import "WPHotViewController.h"
#import "WPEditViewController.h"
#import "WPForMyViewController.h"
#import "WallPapaerADManager.h"
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/ASIdentifierManager.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 {
[[WallPapaerADManager shareInstance] configureAD];
[self checkATT];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[[WallPapaerADManager shareInstance] showFirstOpenAD:^(NSInteger actionType) {
[self configureRootVC];
} window:self.window];
return YES;
}
- (void)configureRootVC {
WPOnePageViewController *wpHome = [[WPOnePageViewController 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];
WPHotViewController *wpHot = [[WPHotViewController 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];
WPEditViewController *wpEdit = [[WPEditViewController 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];
WPForMyViewController *wpMy = [[WPForMyViewController 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 {
[[WallPapaerADManager shareInstance] showOpenAD];
}
- (NSMutableArray *)saveImages{
if (!_saveImages) {
_saveImages = [[NSMutableArray alloc] init];
}
return _saveImages;
}
@end