FqIronsourceInterstitial.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // FqIronsourceInterstitial.m
  3. // XenonSDK
  4. //
  5. // Created by fq on 2021/3/29.
  6. // Copyright © 2021 SAGESSE. All rights reserved.
  7. //
  8. #import "FqIronsourceInterstitial.h"
  9. #import "XSNetwork.h"
  10. @interface FqIronsourceInterstitial()<ISInterstitialDelegate>
  11. @property(nonatomic,assign)BOOL isVideoReadly;
  12. //@property (nonatomic,strong)NSString *adId; //CP传递过来的广告位
  13. @property(nonatomic,strong)void(^InterstitialCallback)(BOOL);
  14. @end
  15. @implementation FqIronsourceInterstitial
  16. -(instancetype)init{
  17. if (self = [super init]) {
  18. self.agentName = @"IronSource"; //平台名称
  19. //self.adUnitId = @"OfferWall";
  20. NSDictionary *infos = [[NSBundle mainBundle] infoDictionary];
  21. self.adUnitId = [infos objectForKey:@"ironsource-Interstitial-unitId"];
  22. self.type = @"Interstotal"; //广告类型
  23. self.unitAdId = @""; //广告组ID
  24. [IronSource setInterstitialDelegate:self];
  25. self.isVideoReadly = false;
  26. [IronSource loadInterstitial];
  27. }
  28. return self;
  29. }
  30. -(BOOL)isAdReady{
  31. return [IronSource hasInterstitial];
  32. }
  33. -(void)openInterstitial:(NSString *)adName callback:(void (^)(BOOL))callback{
  34. self.adId = adName;
  35. self.InterstitialCallback = callback;
  36. dispatch_async(dispatch_get_main_queue(), ^{
  37. UIViewController *vc = [GMTools getViewControl];
  38. [IronSource showInterstitialWithViewController:vc];
  39. });
  40. //数据上报
  41. [XSNetwork adRecord:@"quest" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  42. }
  43. #pragma mark - Interstitial Delegate Functions
  44. - (void)interstitialDidLoad {
  45. self.isVideoReadly = YES;
  46. }
  47. - (void)interstitialDidFailToLoadWithError:(NSError *)error {
  48. self.isVideoReadly = NO;
  49. [IronSource loadInterstitial];
  50. }
  51. - (void)interstitialDidOpen {
  52. }
  53. - (void)interstitialDidShow {
  54. if (self.InterstitialCallback) {
  55. self.InterstitialCallback(self.isVideoReadly);
  56. }
  57. [XSNetwork adRecord:@"show" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  58. }
  59. - (void)interstitialDidFailToShowWithError:(NSError *)error {
  60. self.isVideoReadly = NO;
  61. self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
  62. if (self.InterstitialCallback) {
  63. self.InterstitialCallback(self.isVideoReadly);
  64. }
  65. [IronSource loadInterstitial];
  66. }
  67. - (void)didClickInterstitial {
  68. [XSNetwork adRecord:@"click" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  69. }
  70. - (void)interstitialDidClose {
  71. [XSNetwork adRecord:@"close" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  72. }
  73. @end