FqIronsourceOfferWall.m 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // FqIronsourceOfferWall.m
  3. // XenonSDK
  4. //
  5. // Created by fq on 2021/3/25.
  6. // Copyright © 2021 SAGESSE. All rights reserved.
  7. //
  8. #import "FqIronsourceOfferWall.h"
  9. #import "XSNetwork.h"
  10. @interface FqIronsourceOfferWall()<ISOfferwallDelegate>
  11. @property(nonatomic,assign)BOOL isVideoReadly;
  12. //@property (nonatomic,strong)NSString *adId; //CP传递过来的广告位
  13. @property(nonatomic,strong)void(^offerWallCallback)(BOOL);
  14. @end
  15. @implementation FqIronsourceOfferWall
  16. -(instancetype)init{
  17. if (self = [super init]) {
  18. self.agentName = @"IronSource"; //平台名称
  19. NSDictionary *infos = [[NSBundle mainBundle] infoDictionary];
  20. self.adUnitId = [infos objectForKey:@"ironsource-offerwall-unitId"];
  21. //self.adUnitId = @"OfferWall";
  22. self.type = @"OfferWall"; //广告类型
  23. self.unitAdId = @""; //广告组ID
  24. [IronSource setOfferwallDelegate:self];
  25. self.isVideoReadly = false;
  26. }
  27. return self;
  28. }
  29. -(BOOL)isAdReady{
  30. return [IronSource hasOfferwall];
  31. }
  32. -(void)openOfferWallVideo:(NSString *)adName callback:(void (^)(BOOL))callback{
  33. self.adId = adName;
  34. self.offerWallCallback = callback;
  35. dispatch_async(dispatch_get_main_queue(), ^{
  36. UIViewController *vc = [GMTools getViewControl];
  37. [IronSource showOfferwallWithViewController:vc placement:adName];
  38. });
  39. //数据上报
  40. [XSNetwork adRecord:@"quest" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  41. }
  42. #pragma mark - ISOfferwallDelegate
  43. - (void)offerwallHasChangedAvailability:(BOOL)available {
  44. self.isVideoReadly = available;
  45. }
  46. - (void)offerwallDidShow {
  47. if (self.offerWallCallback) {
  48. self.offerWallCallback(self.isVideoReadly);
  49. }
  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];
  51. }
  52. - (void)offerwallDidFailToShowWithError:(NSError *)error {
  53. //收集错误日志上报服务器.
  54. self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
  55. if (self.offerWallCallback) {
  56. self.offerWallCallback(self.isVideoReadly);
  57. }
  58. }
  59. - (void)offerwallDidClose {
  60. [XSNetwork adRecord:@"close" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  61. }
  62. - (BOOL)didReceiveOfferwallCredits:(NSDictionary *)creditInfo {
  63. return YES;
  64. }
  65. - (void)didFailToReceiveOfferwallCreditsWithError:(NSError *)error {
  66. //NSLog(@"%s",__PRETTY_FUNCTION__);
  67. //收集错误日志上报服务器.
  68. self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
  69. }
  70. @end