123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- //
- // FqIronsourceBanner.m
- // QQQ
- //
- // Created by Mgs on 2020/12/7.
- //
- #import "FqIronsourceBanner.h"
- #import "XSNetwork.h"
- @interface FqIronsourceBanner()<ISBannerDelegate>
- @end
- @implementation FqIronsourceBanner
- -(instancetype)init{
- if (self = [super init]) {
- self.agentName = @"IronSource"; //平台名称
- self.adUnitId = @"ironBanner";
- self.type = @"Banner"; //广告类型
- self.unitAdId = @""; //广告组ID
- [IronSource setBannerDelegate:self];
- }
- return self;
- }
- -(void)openWithSuperView:(UIView *)container{
-
-
- dispatch_async(dispatch_get_main_queue(), ^{
- if (self.bannerView) {
- [IronSource destroyBanner:self.bannerView];
- }
- self.bannerContainer = container;
- UIViewController *vc = [GMTools getViewControl];
- [IronSource loadBannerWithViewController:vc size:ISBannerSize_BANNER];
- });
-
- //数据上报
- [XSNetwork adRecord:@"quest" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
- }
- /**
- Called after a banner ad has been successfully loaded
- */
- - (void)bannerDidLoad:(ISBannerView *)bannerView{
- dispatch_async(dispatch_get_main_queue(), ^{
- self.bannerView = bannerView;
- [bannerView removeFromSuperview];
- [self.bannerContainer addSubview:bannerView];
- CGSize size = [UIScreen mainScreen].bounds.size;
- bannerView.frame = CGRectMake(0, 0, size.width, size.width/320.0*50);
- });
-
- //数据上报
- [XSNetwork adRecord:@"show" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
- }
- /**
- Called after a banner has attempted to load an ad but failed.
-
- @param error The reason for the error
- */
- - (void)bannerDidFailToLoadWithError:(NSError *)error{
-
- //收集错误日志上报服务器.
- self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
- dispatch_async(dispatch_get_main_queue(), ^{
- for (UIView *vi in self.bannerContainer.subviews) {
- [vi removeFromSuperview];
- }
- self.bannerContainer.hidden = true;
- });
- }
- /**
- Called after a banner has been clicked.
- */
- - (void)didClickBanner{
-
- //数据上报
- [XSNetwork adRecord:@"click" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
- }
- /**
- Called when a banner is about to present a full screen content.
- */
- - (void)bannerWillPresentScreen{
-
- }
- /**
- Called after a full screen content has been dismissed.
- */
- - (void)bannerDidDismissScreen{
-
- [XSNetwork adRecord:@"close" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
- }
- /**
- Called when a user would be taken out of the application context.
- */
- - (void)bannerWillLeaveApplication{
-
- }
- @end
|