123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- //
- // FqIronsourceInterstitial.m
- // XenonSDK
- //
- // Created by fq on 2021/3/29.
- // Copyright © 2021 SAGESSE. All rights reserved.
- //
- #import "FqIronsourceInterstitial.h"
- #import "XSNetwork.h"
- @interface FqIronsourceInterstitial()<ISInterstitialDelegate>
- @property(nonatomic,assign)BOOL isVideoReadly;
- @property(nonatomic,strong)void(^InterstitialCallback)(BOOL);
- //广告加载报错次数统计
- @property(nonatomic,assign)NSInteger errorCount;
- @end
- @implementation FqIronsourceInterstitial
- -(instancetype)init{
- if (self = [super init]) {
- self.agentName = @"IronSource"; //平台名称
- NSDictionary *infos = [[NSBundle mainBundle] infoDictionary];
- self.adUnitId = [infos objectForKey:@"ironsource-Interstitial-unitId"];
- self.type = @"Interstotal"; //广告类型
- self.unitAdId = @""; //广告组ID
- [IronSource setInterstitialDelegate:self];
- self.isVideoReadly = false;
- self.errorCount = 0;
-
- [IronSource loadInterstitial];
-
- }
- return self;
- }
- -(BOOL)isAdReady{
-
- return [IronSource hasInterstitial];
- }
- -(void)openInterstitial:(NSString *)adName callback:(void (^)(BOOL))callback{
-
- self.adId = adName;
- self.InterstitialCallback = callback;
- dispatch_async(dispatch_get_main_queue(), ^{
- UIViewController *vc = [GMTools getViewControl];
- [IronSource showInterstitialWithViewController:vc];
- });
- //数据上报
- [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 - Interstitial Delegate Functions
- - (void)interstitialDidLoad {
-
- self.isVideoReadly = YES;
-
- }
- - (void)interstitialDidFailToLoadWithError:(NSError *)error {
- self.isVideoReadly = NO;
-
- //超过3次加载广告资源失败, 直接放弃加载.
- self.errorCount++;
- if (self.errorCount<=3) {
- [IronSource loadInterstitial];
- }
- }
- - (void)interstitialDidOpen {
-
-
- }
- - (void)interstitialDidShow {
-
- if (self.InterstitialCallback) {
- self.InterstitialCallback(self.isVideoReadly);
- }
-
- self.errorCount = 0;
-
- [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)interstitialDidFailToShowWithError:(NSError *)error {
-
- self.isVideoReadly = NO;
- self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
- if (self.InterstitialCallback) {
- self.InterstitialCallback(self.isVideoReadly);
- }
-
- self.errorCount++;
- //超过3次加载广告资源失败, 直接放弃加载.
- if (self.errorCount <=3) {
- [IronSource loadInterstitial];
- }
-
- }
- - (void)didClickInterstitial {
-
- [XSNetwork adRecord:@"click" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
-
- self.errorCount = 0;
-
- }
- - (void)interstitialDidClose {
-
- [XSNetwork adRecord:@"close" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
-
- self.errorCount = 0;
- }
- @end
|