cdts/xdts-ios 3/TreeHole/Code/Features/Login/ViewController/LaunchViewController.m

217 lines
7.9 KiB
Mathematica
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// LaunchViewController.m
// Youth
//
// Created by mambaxie on 2022/1/1.
//
#import "LaunchViewController.h"
#import "PhoneLoginViewController.h"
#import <AdSupport/AdSupport.h>
#import <GeYanSdk/GeYanSdk.h>
//#import <BaiduActionSDK/BaiduAction.h>
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/ASIdentifierManager.h>
@interface LaunchViewController ()
///
@property (assign)BOOL isInitGTQuickAuthorize;
@property (assign)int isDetectAd;
@end
@implementation LaunchViewController
- (BOOL)isSupportContentScrollView {
return YES;
}
- (BOOL)mt_nagationBarTransparent {
return YES;
}
/*
- (void)getuiPreDeal {
if (self.isInitGTQuickAuthorize) {
return;
}
//
[GeYanSdk startWithAppId:GETUI_APPID withTimeout:30 withCallback:^(BOOL isSuccess, NSError * _Nullable error, NSString * _Nullable gyUid) {
;
if (!error) { //
if (gyUid == nil) {
[SVProgressHUD showErrorWithStatus:@"一键登录失败gyUid空请使用验证码登录"];
return;
}
self.isInitGTQuickAuthorize = YES;
[PYAppService sharedService].gyUid = gyUid;
[GeYanSdk preGetToken:^(NSDictionary *tokenDic) {
if ([tokenDic[@"code"] intValue] == 30000) {
[PYAppService sharedService].gyPreTokenDic = tokenDic;
}
NSLog(@"获取token返回结果%@", tokenDic);
}];
}else{
// [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"一键登录失败%@,请使用验证码登录", error]];
[SVProgressHUD showErrorWithStatus:@"一键登录未能正常接通,请检查手机卡或网络是否正常"];
}
}];
// [BaiduAction logAction:BaiduSDKActionNamePurchase actionParam:
// @{
// }];
}
*/
- (void)viewDidLoad {
// _isInitGetui = 0;
_isDetectAd = 0;
[super viewDidLoad];
UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
UIImage *bgImage = ImageNamed(@"TH_login_start_bg");
bgImageView.width = SCREEN_WIDTH;
bgImageView.image = bgImage;
bgImageView.height = SCREEN_WIDTH * bgImage.size.height / bgImage.size.width;
bgImageView.contentMode = UIViewContentModeScaleAspectFit;
bgImageView.backgroundColor = [UIColor clearColor];
// bgImageView.height = bgImage.size.height / bgImage.size.width * bgImageView.width;
[self.view addSubview:bgImageView];
UIImageView *maskView = [[UIImageView alloc] init];
maskView.width = SCREEN_WIDTH;
UIImage *maskImage = ImageNamed(@"TH_login_img");
maskView.image = maskImage;
maskView.height = SCREEN_WIDTH * maskImage.size.height / maskImage.size.width;
maskView.bottom = self.view.height;
[self.view addSubview:maskView];
UIView *loginActionView = [[UIView alloc] init];
loginActionView.x = FIX_SIZE(73);
loginActionView.height = FIX_SIZE(52);
loginActionView.layer.cornerRadius = FIX_SIZE(20);
loginActionView.width = SCREEN_WIDTH - loginActionView.x * 2;
loginActionView.layer.borderWidth = 1;
loginActionView.backgroundColor = [UIColor clearColor];
loginActionView.layer.borderColor = [UIColor colorWithWhite:1.0 alpha:0.5].CGColor;
loginActionView.centerX = SCREEN_WIDTH * 0.5;
loginActionView.bottom = SCREEN_HEIGHT - FIX_SIZE(70) - homeIndicatorHeight();
UIView *contentView = [[UIView alloc] init];
contentView.height = loginActionView.height;
contentView.backgroundColor = [UIColor clearColor];
UIImageView *iconImageView = [[UIImageView alloc] init];
iconImageView.size = CGSizeMake(FIX_SIZE(21), FIX_SIZE(21));
iconImageView.centerY = contentView.height * 0.5;
iconImageView.backgroundColor = [UIColor clearColor];
iconImageView.contentMode = UIViewContentModeScaleAspectFit;
NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"TH_login_enter"] ofType:@"png"];
[iconImageView sd_setImageWithURL:[NSURL fileURLWithPath:path]];
[contentView addSubview:iconImageView];
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.font = MT_FONT_MEDIUM_SIZE(15);
titleLabel.textColor = [UIColor whiteColor];
titleLabel.text = @"进入畅聊小酒馆";
[titleLabel sizeToFit];
titleLabel.centerY = contentView.height * 0.5;
titleLabel.x = iconImageView.right + FIX_SIZE(6);
[contentView addSubview:titleLabel];
contentView.width = titleLabel.right;
contentView.centerX = loginActionView.width * 0.5;
[loginActionView addSubview:contentView];
[loginActionView addTapWithAction:^{
[PYAppService pushViewControllerAnimated:[PhoneLoginViewController new]];
}];
[self.view addSubview:loginActionView];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewWillDisappear:animated];
/*
if ([PYHTTPManager isNetReachable]) {
[self getuiPreDeal];
[self getIDFA];
// [BaiduAction logAction:BaiduSDKActionNamePurchase actionParam:
// @{
// }];
}else{
[PYHTTPManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
if (status == AFNetworkReachabilityStatusReachableViaWWAN || status == AFNetworkReachabilityStatusReachableViaWiFi) {
[self getuiPreDeal];
[self getIDFA];
}else{
//idfa
}
}];
}
*/
}
- (void)getIDFA{
NSString *invalidIdfa = @"00000000-0000-0000-0000-000000000000";
if (@available(iOS 14, *)) {
// iOS14
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
// 使idfa
if (status == ATTrackingManagerAuthorizationStatusAuthorized || status == ATTrackingManagerAuthorizationStatusNotDetermined) {
NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
NSLog(@"%@",idfa);
//idfa
if (![idfa isEqualToString:invalidIdfa]) {
[UserService setIdfa:idfa];
// [PYHTTPManager postWithPath:@"uploadidfa" params:@{@"idfa": idfa} callback:^(id _Nullable rsp, NSError * _Nullable error) {
// //
// }];
}
[self detectionAd];
} else {
NSLog(@"请在设置-隐私-Tracking中允许App请求跟踪");
}
}];
} else {
// iOS14使
// -广
if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
//idfa
if (![idfa isEqualToString:invalidIdfa]) {
[UserService setIdfa:idfa];
// [PYHTTPManager postWithPath:@"uploadidfa" params:@{@"idfa": idfa} callback:^(id _Nullable rsp, NSError * _Nullable error) {
// //
// }];
}
[self detectionAd];
} else {
NSLog(@"请在设置-隐私-广告中打开广告跟踪功能");
}
}
}
- (void)detectionAd{
if (_isDetectAd > 0) {
return;
}
if ([UserService registerListenerSucceed] == 0) {
_isDetectAd = 1;
///
[PYHTTPManager postWithPath:@"lanuchconfigs" params:@{@"idfa": [UserService idfa]} callback:^(id _Nullable rsp, NSError * _Nullable error) {
if (!error) {
}
}];
}
}
- (void)dealloc{
[PYHTTPManager setReachabilityStatusChangeBlock:nil];
}
@end