2、开屏广告

开屏广告的实现

准备工作:(我们准备了两种方式实现开屏广告,建议用第一种)

第一种方案(弹出Viewcontroller展示广告):

(1)导入框架
#import <AdverTestSDK/AdverNewVObjc.h>//获取数据
#import <AdverTestSDK/OpenImgAdObjc.h>//展示开屏图片广告
#import <AdverTestSDK/TVAdverObjc.h>//展示开屏视屏广告
(2)添加支持横竖屏的文件#import “OrienOb.h”和#import “OrienOb.m”(如果项目中不需要同时兼容横竖屏,则不需要该方法)<此方法也可以按个人喜好自己写>

1、开屏广告的获取数据和代理方法

//1、代理
@property(nonatomic,weak)id<AdverNewVObjcDelegate> adverNewVObjcDelegate;

//2、获取数据方法
-(void)getDataWithOpenImg;//获取开屏广告数据
-(void)getDataWithOpenLogoLogo;//获取开屏带logo广告数据
-(void)getDataWithOpenTV;//获取开屏视频广告数据

//3、代理方法
//开屏
- (void)getDataOpenImg:(BOOL)success;//开屏获取数据成功代理
//开屏带logo
- (void)getDataOpenLogoLogo:(BOOL)success;//开屏带logo获取数据成功代理
//开屏视频  
- (void)getDataOpenTV:(BOOL)success;//开屏视频获取数据成功代理

2、加载广告
(1)加载开屏图片广告

//1、添加代理
@interface OpenImgAdverViewC ()<AdverNewVObjcDelegate,OpenImgAdObjcDelegate>

//2、定义
@property(nonatomic,strong) AdverNewVObjc * adverNewVObjc;
@property(nonatomic,strong) OpenImgAdObjc * openImgAdObjc;

//3、获取数据
_adverNewVObjc = [AdverNewVObjc alloc];
_adverNewVObjc.adverNewVObjcDelegate = self;
if(需要普通开屏图片广告){
[_adverNewVObjc getDataWithOpenImg];//获取开屏广告数据
}else if(需要开屏带logo的广告数据){//
        [_adverNewVObjc getDataWithOpenLogoLogo];//获取开屏带logo的广告数据
    }


//4、获取开屏数据代理 展示广告
- (void)getDataOpenImg:(BOOL)success{
    if (success) {
    _openImgAdObjc = [OpenImgAdObjc alloc];
    _openImgAdObjc.openImgAdObjcDelegate = self;
        [_openImgAdObjc showImgAdver:self withIsLogo:NO];
    }
}

//4、 获取开屏带logo代理
- (void)getDataOpenLogoLogo:(BOOL)success{
    if (success) {
    _openImgAdObjc = [OpenImgAdObjc alloc];
    _openImgAdObjc.openImgAdObjcDelegate = self;
        [_openImgAdObjc showImgAdver:self withIsLogo:YES];
    }
}

//5 展示广告代理(图片开屏广告代理都一样)
-(void)tagImgViewOpenImgAdObjcClicked{
    NSLog(@"点击广告代理");
}
//手动关闭广告代理
-(void)selfImgViewOpenImgAdCloseAdClicked{
    NSLog(@"手动关闭广告代理");
}
//广告播放结束,自动关闭广告
-(void)overTimeImgViewOpenImgAdAd{
    NSLog(@"广告播放结束,自动关闭广告");
}
//点击了反馈广告,关闭广告,
-(void)tagAdverImgViewOpenImgAdFankuiWithContent:(NSString *)content{
    NSLog(@"点击了反馈广告,关闭广告,%@",content);
}
//手动关闭广告,弹出反馈按钮和关闭
-(void)closeAdOpenImgAdObjcWithShowFankui{
    NSLog(@"手动关闭广告,弹出反馈按钮和关闭");
}
//手动关闭广告,弹出反馈按钮和关闭,又点击了关闭按钮,从而关闭广告
-(void)closeAdOpenImgAdObjcWithShowFankuiAndTagCloseBtn{
    NSLog(@"手动关闭广告,弹出反馈按钮和关闭,又点击了关闭按钮,从而关闭广告");
}
//移除广告
-(void)removeAdCImgViewOpenImgAd{
    //开放屏幕旋转
    [[OrienOb sharedOrienObInit] maskOrienObj];
    NSLog(@"移除广告");
}

(2)加载开屏视频广告

//1、代理及定义
@interface TVAdverVC ()<AdverNewVObjcDelegate,TVAdverObjcDelegate>
@property(nonatomic,strong) AdverNewVObjc * adverNewVObjc;
@property(nonatomic,strong) TVAdverObjc * tvAdverObjc;

//2、获取数据
_adverNewVObjc = [AdverNewVObjc alloc];
    _adverNewVObjc.adverNewVObjcDelegate = self;
    //开屏视屏数据获取
        [_adverNewVObjc getDataWithOpenTV];

//3、在获取数据代理方法里面展示广告
#pragma mark 开屏视频获取数据成功代理
- (void)getDataOpenTV:(BOOL)success{
    if (success) {
    _tvAdverObjc = [TVAdverObjc alloc];
    _tvAdverObjc.tvAdverObjcDelegate = self;
        [_tvAdverObjc showTVAdver:self];
    }
}

//4、展示广告代理方法
#pragma mark 视频广告展示事件代理
//点击广告代理
-(void)tagTVAdverObjcClicked{
    NSLog(@"点击广告代理");
}

//手动关闭广告代理
-(void)selfTVAdverObjcCloseAdClicked{
    NSLog(@"手动关闭广告代理");
}

//广告播放结束,自动关闭广告
-(void)overTimeTVAdverObjc{
    NSLog(@"广告播放结束,自动关闭广告");
}

//点击了反馈广告,关闭广告,
-(void)tagAdverTVAdverObjcFankuiWithContent:(NSString *)content{
    NSLog(@"点击了反馈广告,关闭广告,%@",content);
}

//手动关闭广告,弹出反馈按钮和关闭
-(void)closeTVAdverObjcWithShowFankui{
    NSLog(@"手动关闭广告,弹出反馈按钮和关闭");
}

//手动关闭广告,弹出反馈按钮和关闭,又点击了关闭按钮,从而关闭广告
-(void)closeTVAdverObjcWithShowFankuiAndTagCloseBtn{
    NSLog(@"手动关闭广告,弹出反馈按钮和关闭,又点击了关闭按钮,从而关闭广告");
}

//移除广告
-(void)removeTVAdverObjcDelegate{
    NSLog(@"移除广告");
    //开放屏幕旋转
    [[OrienOb sharedOrienObInit] maskOrienObj];
}

以上是一种方法加载,下面说第二种方法(返回UIView)

所在文件:@interface AdverNewVObjc : NSObject
代理:@property(nonatomic,weak)id<AdverNewVObjcDelegate> adverNewVObjcDelegate;

1、获取数据方法:

#pramg mark 获取数据方法
-(void)getDataWithOpenImg;//获取开屏广告数据
-(void)getDataWithOpenLogoLogo;//获取开屏带logo广告数据

-(void)getDataWithOpenTV;//获取开屏视频广告数据

2、代理方法

#pramg mark 获取数据成功/失败代理方法
- (void)getDataOpenImg:(BOOL)success;//开屏获取数据成功代理
- (void)getDataOpenLogoLogo:(BOOL)success;//开屏带logo获取数据成功代理

- (void)getDataOpenTV:(BOOL)success;//开屏视频获取数据成功代理

3、实现

(1)导入文件,并注明代理,定义文件
#import <AdverTestSDK/AdverNewVObjc.h>
@interface ViewController ()<AdverNewVObjcDelegate>
@property(nonatomic,strong) AdverNewVObjc * adverNewVObjc;

(2)确认代理
_adverNewVObjc = [AdverNewVObjc alloc]; 
_adverNewVObjc.adverNewVObjcDelegate = self;

(3)获取数据
[_adverNewVObjc getDataWithOpenImg];//获取开屏广告数据
[_adverNewVObjc getDataWithOpenLogoLogo];//获取开屏带logo广告数据
[_adverNewVObjc getDataWithOpenTV];//获取开屏视频广告数据


(4)代理方实现
#pragma mark AdverNewVObjcDelegate 一对一代理
//开屏获取数据成功代理
- (void)getDataOpenImg:(BOOL)success{
    if (success) {
        //开屏图片广告
        [ImgViewObject initKaiPingData];
        [[OrienOb sharedOrienObInit] isTurnOrienObj];
        [ImgViewObject creatLaunchImgView:self withEndBlock:^{
            NSLog(@"手动关闭Block");
            [[OrienOb sharedOrienObInit] maskOrienObj];
        } withZidongClose:^{
            [[OrienOb sharedOrienObInit] maskOrienObj];
            NSLog(@"自动关闭Block");
        } withTagAdver:^{
            NSLog(@"点击广告Block");
        }];
    }
}

//开屏带logo获取数据成功代理
- (void)getDataOpenLogoLogo:(BOOL)success{
    if (success) {
        [[OrienOb sharedOrienObInit] isTurnOrienObj];
        [ImgViewObject initKaiPingData];
        [ImgViewObject creatLoGoImgView:self withEndBlock:^{
            NSLog(@"手动关闭Block");
            [[OrienOb sharedOrienObInit] maskOrienObj];
        } withZidongClose:^{
            [[OrienOb sharedOrienObInit] maskOrienObj];
            NSLog(@"自动关闭Block");
        } withTagAdver:^{

            NSLog(@"点击广告Block");
        }];
    }
}


//开屏视频获取数据成功代理
- (void)getDataOpenTV:(BOOL)success{
    if (success) {
        [[OrienOb sharedOrienObInit] isTurnOrienObj];
        [ImgViewObject initKaiPingData];
        [ImgViewObject creatLaunchTVView:self withEndBlock:^{
            [[OrienOb sharedOrienObInit] maskOrienObj];
            NSLog(@"手动关闭Block");
        } withZidongClose:^{
            [[OrienOb sharedOrienObInit] maskOrienObj];
            NSLog(@"自动关闭Block");
        } withTagAdver:^{
            NSLog(@"点击广告Block");
        }];
    }
}