// // FqIronsourceOfferWall.m // XenonSDK // // Created by fq on 2021/3/25. // Copyright © 2021 SAGESSE. All rights reserved. // #import "FqIronsourceOfferWall.h" #import "XSNetwork.h" @interface FqIronsourceOfferWall() @property(nonatomic,assign)BOOL isVideoReadly; //@property (nonatomic,strong)NSString *adId; //CP传递过来的广告位 @property(nonatomic,strong)void(^offerWallCallback)(BOOL); @end @implementation FqIronsourceOfferWall -(instancetype)init{ if (self = [super init]) { self.agentName = @"IronSource"; //平台名称 NSDictionary *infos = [[NSBundle mainBundle] infoDictionary]; self.adUnitId = [infos objectForKey:@"ironsource-offerwall-unitId"]; //self.adUnitId = @"OfferWall"; self.type = @"OfferWall"; //广告类型 self.unitAdId = @""; //广告组ID [IronSource setOfferwallDelegate:self]; self.isVideoReadly = false; } return self; } -(BOOL)isAdReady{ return [IronSource hasOfferwall]; } -(void)openOfferWallVideo:(NSString *)adName callback:(void (^)(BOOL))callback{ self.adId = adName; self.offerWallCallback = callback; dispatch_async(dispatch_get_main_queue(), ^{ UIViewController *vc = [GMTools getViewControl]; [IronSource showOfferwallWithViewController:vc placement:adName]; }); //数据上报 [XSNetwork adRecord:@"quest" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg]; } #pragma mark - ISOfferwallDelegate - (void)offerwallHasChangedAvailability:(BOOL)available { self.isVideoReadly = available; } - (void)offerwallDidShow { if (self.offerWallCallback) { self.offerWallCallback(self.isVideoReadly); } [XSNetwork adRecord:@"show" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg]; } - (void)offerwallDidFailToShowWithError:(NSError *)error { //收集错误日志上报服务器. self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo]; if (self.offerWallCallback) { self.offerWallCallback(self.isVideoReadly); } } - (void)offerwallDidClose { [XSNetwork adRecord:@"close" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg]; } - (BOOL)didReceiveOfferwallCredits:(NSDictionary *)creditInfo { return YES; } - (void)didFailToReceiveOfferwallCreditsWithError:(NSError *)error { //NSLog(@"%s",__PRETTY_FUNCTION__); //收集错误日志上报服务器. self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo]; } @end