217 lines
7.9 KiB
Objective-C
217 lines
7.9 KiB
Objective-C
//
|
||
// 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
|