sd
This commit is contained in:
parent
58d81bd881
commit
988b3e7a4f
Binary file not shown.
@ -146,6 +146,7 @@
|
|||||||
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
||||||
LuxADSSModeVC *vc = [LuxADSSModeVC new];
|
LuxADSSModeVC *vc = [LuxADSSModeVC new];
|
||||||
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
|
||||||
|
nav.navigationBarHidden = YES;
|
||||||
keyWindow.rootViewController = nav;
|
keyWindow.rootViewController = nav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,11 +10,34 @@
|
|||||||
#import "LuxADManager.h"
|
#import "LuxADManager.h"
|
||||||
|
|
||||||
@interface LuxADSSButton : UIButton
|
@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
|
@end
|
||||||
|
|
||||||
@implementation LuxADSSButton
|
@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
|
@end
|
||||||
|
|
||||||
@interface LuxADSSModeVC ()
|
@interface LuxADSSModeVC ()
|
||||||
@ -29,13 +52,14 @@
|
|||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
|
// self.view.backgroundColor = [UIColor redColor];
|
||||||
|
self.navigationController.navigationBarHidden = YES;
|
||||||
__block CGFloat currY = 80.0;
|
__block CGFloat currY = 50.0;
|
||||||
CGFloat cellHeight = 50;
|
CGFloat cellHeight = 50;
|
||||||
CGFloat cellPadding = 20;
|
CGFloat cellPadding = 20;
|
||||||
CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
|
CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
|
||||||
@ -46,7 +70,7 @@
|
|||||||
[[[LuxADManager shareInstance] allInterstitialAds] enumerateObjectsUsingBlock:^(LuxADManagerInterstitialItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
[[[LuxADManager shareInstance] allInterstitialAds] enumerateObjectsUsingBlock:^(LuxADManagerInterstitialItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
CGRect rect = CGRectMake(cellPadding, currY, cellWidth, cellHeight);
|
CGRect rect = CGRectMake(cellPadding, currY, cellWidth, cellHeight);
|
||||||
LuxADSSButton *button = [LuxADSSButton new];
|
LuxADSSButton *button = [LuxADSSButton new];
|
||||||
button.item = obj;
|
[button setADItem:obj];
|
||||||
button.frame = rect;
|
button.frame = rect;
|
||||||
button.tag = idx + 1;
|
button.tag = idx + 1;
|
||||||
obj.tapPointX = @(button.center.x);
|
obj.tapPointX = @(button.center.x);
|
||||||
@ -59,10 +83,11 @@
|
|||||||
|
|
||||||
[self.view addSubview:button];
|
[self.view addSubview:button];
|
||||||
currY += cellPadding + cellHeight;
|
currY += cellPadding + cellHeight;
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
_adInfoTextView = [UITextView new];
|
_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];
|
[self.view addSubview:_adInfoTextView];
|
||||||
_adInfoTextView.backgroundColor = [UIColor purpleColor];
|
_adInfoTextView.backgroundColor = [UIColor purpleColor];
|
||||||
_adInfoTextView.editable = NO;
|
_adInfoTextView.editable = NO;
|
||||||
@ -71,7 +96,7 @@
|
|||||||
_adInfoTextView.layoutManager.allowsNonContiguousLayout = NO;
|
_adInfoTextView.layoutManager.allowsNonContiguousLayout = NO;
|
||||||
|
|
||||||
_actionTextView = [UITextView new];
|
_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];
|
[self.view addSubview:_actionTextView];
|
||||||
_actionTextView.backgroundColor = [UIColor lightGrayColor];
|
_actionTextView.backgroundColor = [UIColor lightGrayColor];
|
||||||
_actionTextView.editable = NO;
|
_actionTextView.editable = NO;
|
||||||
@ -83,8 +108,14 @@
|
|||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionInfoNtification:) name:kLuxADSSModeVC_Notification_ActionInfo object:nil];
|
[[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 {
|
- (void)clickAction:(LuxADSSButton *)sender {
|
||||||
sender.item.actionBlock(self);
|
sender.item.actionBlock(self);
|
||||||
|
sender.clickCount += 1;
|
||||||
NSLog(@"rect:%@",NSStringFromCGRect(sender.frame));
|
NSLog(@"rect:%@",NSStringFromCGRect(sender.frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@
|
|||||||
[mdic setObject:@"uploadAD_Show" forKey:@"shelfNumber"];
|
[mdic setObject:@"uploadAD_Show" forKey:@"shelfNumber"];
|
||||||
[mdic setObject:@(ad.revenue) forKey:@"ecpm"];
|
[mdic setObject:@(ad.revenue) forKey:@"ecpm"];
|
||||||
[mdic setObject:@0.0 forKey:@"getIpResponseTime"];
|
[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:@"dataId"];
|
||||||
[mdic setObject:@"" forKey:@"linkId"];
|
[mdic setObject:@"" forKey:@"linkId"];
|
||||||
[mdic setObject:@0 forKey:@"loadTime"];
|
[mdic setObject:@0 forKey:@"loadTime"];
|
||||||
@ -164,7 +164,7 @@
|
|||||||
[mdic setObject:@"uploadAD_Load" forKey:@"shelfNumber"];
|
[mdic setObject:@"uploadAD_Load" forKey:@"shelfNumber"];
|
||||||
[mdic setObject:@(ad.revenue) forKey:@"ecpm"];
|
[mdic setObject:@(ad.revenue) forKey:@"ecpm"];
|
||||||
[mdic setObject:@0.0 forKey:@"getIpResponseTime"];
|
[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:@"dataId"];
|
||||||
[mdic setObject:@"" forKey:@"linkId"];
|
[mdic setObject:@"" forKey:@"linkId"];
|
||||||
[mdic setObject:@0 forKey:@"loadTime"];
|
[mdic setObject:@0 forKey:@"loadTime"];
|
||||||
@ -188,7 +188,7 @@
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NSLog(@"222222222222: %@", result);
|
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
|
//请求远程ip
|
||||||
+ (void)requestRemoteIp {
|
+ (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];
|
NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
||||||
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||||
if(error) {
|
if(error) {
|
||||||
@ -206,12 +209,14 @@
|
|||||||
else {
|
else {
|
||||||
id result = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
|
id result = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
|
||||||
if(result) {
|
if(result) {
|
||||||
NSString *ip = result[@"ip"];
|
NSString *ip = result[@"data"][@"ip"];
|
||||||
|
NSString *ip_isoCode = result[@"data"][@"isoCode"];
|
||||||
if(ip.length) {
|
if(ip.length) {
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:ip forKey:@"kIP_key"];
|
[[NSUserDefaults standardUserDefaults] setObject:ip forKey:@"kIP_key"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:ip forKey:@"kIP_key_isoCode"];
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
[[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 {
|
else {
|
||||||
NSLog(@"解析ip失败....");
|
NSLog(@"解析ip失败....");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user