diff --git a/HD wallpaper.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate b/HD wallpaper.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate index 3b19e00..c3abb96 100644 Binary files a/HD wallpaper.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate and b/HD wallpaper.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/HDwallpaper/LuxADManager/LuxADManager.m b/HDwallpaper/LuxADManager/LuxADManager.m index 5b349d6..0a22ed6 100644 --- a/HDwallpaper/LuxADManager/LuxADManager.m +++ b/HDwallpaper/LuxADManager/LuxADManager.m @@ -146,6 +146,7 @@ UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; LuxADSSModeVC *vc = [LuxADSSModeVC new]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; + nav.navigationBarHidden = YES; keyWindow.rootViewController = nav; } diff --git a/HDwallpaper/LuxADManager/LuxADSSModeVC.m b/HDwallpaper/LuxADManager/LuxADSSModeVC.m index 2999886..318c82e 100644 --- a/HDwallpaper/LuxADManager/LuxADSSModeVC.m +++ b/HDwallpaper/LuxADManager/LuxADSSModeVC.m @@ -10,11 +10,34 @@ #import "LuxADManager.h" @interface LuxADSSButton : UIButton -@property (nonatomic,weak) LuxADManagerInterstitialItem *item; +@property (nonatomic,strong) LuxADManagerInterstitialItem *item; +@property (nonatomic) NSInteger clickCount; +- (void)setADItem:(LuxADManagerInterstitialItem *)item; +@property (nonatomic,strong) NSTimer *checkTimer; @end @implementation LuxADSSButton +- (void)setADItem:(LuxADManagerInterstitialItem *)item { + _clickCount = 0; + _item = item; + self.backgroundColor = item.adItem.isReady ? [UIColor blueColor] : [UIColor orangeColor]; + _checkTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(checkIsReady) userInfo:nil repeats:YES]; +} + +- (void)setClickCount:(NSInteger)clickCount{ + _clickCount = clickCount; + [self setTitle:[NSString stringWithFormat:@"ID:%@ CN:%ld",_item.adItem.adUnitIdentifier,(long)_clickCount] forState:UIControlStateNormal]; +} + +- (void)dealloc { + [_checkTimer invalidate]; + _checkTimer = nil; +} + +- (void)checkIsReady { + self.backgroundColor = _item.adItem.isReady ? [UIColor blueColor] : [UIColor orangeColor]; +} @end @interface LuxADSSModeVC () @@ -29,13 +52,14 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + } - (void)viewDidLoad { [super viewDidLoad]; - - - __block CGFloat currY = 80.0; +// self.view.backgroundColor = [UIColor redColor]; + self.navigationController.navigationBarHidden = YES; + __block CGFloat currY = 50.0; CGFloat cellHeight = 50; CGFloat cellPadding = 20; CGFloat screenW = [UIScreen mainScreen].bounds.size.width; @@ -46,7 +70,7 @@ [[[LuxADManager shareInstance] allInterstitialAds] enumerateObjectsUsingBlock:^(LuxADManagerInterstitialItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { CGRect rect = CGRectMake(cellPadding, currY, cellWidth, cellHeight); LuxADSSButton *button = [LuxADSSButton new]; - button.item = obj; + [button setADItem:obj]; button.frame = rect; button.tag = idx + 1; obj.tapPointX = @(button.center.x); @@ -59,10 +83,11 @@ [self.view addSubview:button]; currY += cellPadding + cellHeight; + }]; _adInfoTextView = [UITextView new]; - _adInfoTextView.frame = CGRectMake(0, currY, screenW*0.5, screenH - currY - 10); + _adInfoTextView.frame = CGRectMake(0, currY, screenW*0.5, screenH - currY); [self.view addSubview:_adInfoTextView]; _adInfoTextView.backgroundColor = [UIColor purpleColor]; _adInfoTextView.editable = NO; @@ -71,7 +96,7 @@ _adInfoTextView.layoutManager.allowsNonContiguousLayout = NO; _actionTextView = [UITextView new]; - _actionTextView.frame = CGRectMake(_adInfoTextView.frame.size.width, _adInfoTextView.frame.origin.y, _adInfoTextView.frame.size.width, _adInfoTextView.frame.size.height); + _actionTextView.frame = CGRectMake(screenW - _adInfoTextView.frame.size.width, _adInfoTextView.frame.origin.y, _adInfoTextView.frame.size.width, _adInfoTextView.frame.size.height); [self.view addSubview:_actionTextView]; _actionTextView.backgroundColor = [UIColor lightGrayColor]; _actionTextView.editable = NO; @@ -83,8 +108,14 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionInfoNtification:) name:kLuxADSSModeVC_Notification_ActionInfo object:nil]; } +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + self.navigationController.navigationBarHidden = YES; +} + - (void)clickAction:(LuxADSSButton *)sender { sender.item.actionBlock(self); + sender.clickCount += 1; NSLog(@"rect:%@",NSStringFromCGRect(sender.frame)); } diff --git a/HDwallpaper/LuxADManager/LuxNetManager.m b/HDwallpaper/LuxADManager/LuxNetManager.m index fe9cf33..b332a6d 100644 --- a/HDwallpaper/LuxADManager/LuxNetManager.m +++ b/HDwallpaper/LuxADManager/LuxNetManager.m @@ -118,7 +118,7 @@ [mdic setObject:@"uploadAD_Show" forKey:@"shelfNumber"]; [mdic setObject:@(ad.revenue) forKey:@"ecpm"]; [mdic setObject:@0.0 forKey:@"getIpResponseTime"]; - [mdic setObject:ad.DSPName forKey:@"dsp"]; + [mdic setObject:ad.DSPName?ad.DSPName:@"MAX" forKey:@"dsp"]; [mdic setObject:@"" forKey:@"dataId"]; [mdic setObject:@"" forKey:@"linkId"]; [mdic setObject:@0 forKey:@"loadTime"]; @@ -164,7 +164,7 @@ [mdic setObject:@"uploadAD_Load" forKey:@"shelfNumber"]; [mdic setObject:@(ad.revenue) forKey:@"ecpm"]; [mdic setObject:@0.0 forKey:@"getIpResponseTime"]; - [mdic setObject:ad.DSPName forKey:@"dsp"]; + [mdic setObject:ad.DSPName?ad.DSPName:@"MAX" forKey:@"dsp"]; [mdic setObject:@"" forKey:@"dataId"]; [mdic setObject:@"" forKey:@"linkId"]; [mdic setObject:@0 forKey:@"loadTime"]; @@ -188,7 +188,7 @@ } else { NSLog(@"222222222222: %@", result); - [[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_AdInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"AdID:%@ 广告加载成功,ecpm:%@ 加载时长:%dms dsp:%@ network:%@",ad.adUnitIdentifier,@(ad.revenue),@(ad.requestLatency*1000).integerValue,ad.DSPName,ad.networkName]}]; + [[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_AdInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"AdID:%@ 广告加载成功,ecpm:%@ 加载时长:%dms dsp:%@ network:%@",ad.adUnitIdentifier,@(ad.revenue),@(ad.requestLatency*1000).integerValue,ad.DSPName?ad.DSPName:@"MAX",ad.networkName]}]; } }]; @@ -196,7 +196,10 @@ //请求远程ip + (void)requestRemoteIp { - NSURL *url = [NSURL URLWithString:@"https://api.ipify.org/?format=json"]; + + [[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_ActionInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"获取ip中..."]}]; + + NSURL *url = [NSURL URLWithString:@"https://openapi.lux-ad.com/app/common/getIPInfo"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { if(error) { @@ -206,12 +209,14 @@ else { id result = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; if(result) { - NSString *ip = result[@"ip"]; + NSString *ip = result[@"data"][@"ip"]; + NSString *ip_isoCode = result[@"data"][@"isoCode"]; if(ip.length) { [[NSUserDefaults standardUserDefaults] setObject:ip forKey:@"kIP_key"]; + [[NSUserDefaults standardUserDefaults] setObject:ip forKey:@"kIP_key_isoCode"]; [[NSUserDefaults standardUserDefaults] synchronize]; - [[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_AdInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"当前ip:%@",ip]}]; + [[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_AdInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"当前ip:%@ \n国家:%@ ",ip,ip_isoCode]}]; } else { NSLog(@"解析ip失败....");