// // FqIronsourceBanner.m // QQQ // // Created by Mgs on 2020/12/7. // #import "FqIronsourceBanner.h" #import "XSNetwork.h" @interface FqIronsourceBanner() @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