sd
This commit is contained in:
parent
58d81bd881
commit
988b3e7a4f
Binary file not shown.
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
@ -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失败....");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user