ISAdOfferWall.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // ISAdOfferWall.m
  3. // XenonSDK
  4. //
  5. // Created by fq on 2020/12/25.
  6. // Copyright © 2020 SAGESSE. All rights reserved.
  7. //
  8. #import "ISAdOfferWall.h"
  9. #import <IronSource/IronSource.h>
  10. #import "XSNetwork.h"
  11. @interface ISAdOfferWall()<ISOfferwallDelegate>
  12. //是否加载好
  13. @property (nonatomic, assign)BOOL ready;
  14. @end
  15. @implementation ISAdOfferWall
  16. - (instancetype)init
  17. {
  18. self = [super init];
  19. if (self) {
  20. self.ready = NO;
  21. self.adId = @""; //广告位名称
  22. self.agentName = @"ironsource"; //平台名称
  23. self.medium = @""; //中介
  24. self.adUnitId = @"Rewarded"; //原平台单元id
  25. self.type = @"Rewarded"; //广告类型
  26. self.unitAdId = @""; //广告组ID
  27. self.errorMsg = @""; //错误信息
  28. //init
  29. [IronSource setOfferwallDelegate:self];
  30. }
  31. return self;
  32. }
  33. - (BOOL)isReady {
  34. return self.ready;
  35. }
  36. - (void)play:(NSString *)adId callback:(void (^)(int))back {
  37. [XSNetwork adRecord:@"quest" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  38. if (self.ready) {
  39. UIWindow *window = [self currentWindow];
  40. if (window) {
  41. [IronSource showOfferwallWithViewController:window.rootViewController];
  42. }
  43. }
  44. }
  45. #pragma mark - ISOfferwallDelegate
  46. // This method gets invoked after the availability of the Offerwall changes.
  47. - (void)offerwallHasChangedAvailability:(BOOL)available {
  48. NSLog(@"%s", __PRETTY_FUNCTION__);
  49. NSLog(@"ironsource ISAdRewarded rewardedVideoHasChangedAvailability :%d",available);
  50. self.ready = available;
  51. }
  52. // This method gets invoked each time the Offerwall loaded successfully.
  53. - (void)offerwallDidShow {
  54. NSLog(@"%s",__PRETTY_FUNCTION__);
  55. [XSNetwork adRecord:@"show" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  56. }
  57. // This method gets invoked after a failed attempt to load the Offerwall.
  58. // If it does happen, check out 'error' for more information and consult our
  59. // Knowledge center.
  60. - (void)offerwallDidFailToShowWithError:(NSError *)error {
  61. NSLog(@"%s",__PRETTY_FUNCTION__);
  62. //收集错误日志上报服务器.
  63. self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
  64. }
  65. // This method gets invoked after the user had clicked the little
  66. // 'x' button at the top-right corner of the screen.
  67. - (void)offerwallDidClose {
  68. NSLog(@"%s",__PRETTY_FUNCTION__);
  69. [XSNetwork adRecord:@"close" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
  70. }
  71. // This method will be called each time the user has completed an offer.
  72. // All relative information is stored in 'creditInfo' and it is
  73. // specified in more detail in 'SupersonicOWDelegate.h'.
  74. // If you return NO the credit for the last offer will be added to
  75. // Everytime you return 'NO' we aggragate the credit and return it all
  76. // at one time when you return 'YES'.
  77. - (BOOL)didReceiveOfferwallCredits:(NSDictionary *)creditInfo {
  78. NSLog(@"%s",__PRETTY_FUNCTION__);
  79. NSLog(@"didReceiveOfferwallCredits:%@",creditInfo);
  80. return YES;
  81. }
  82. // This method get invoked when the ‘-getOWCredits’ fails to retrieve
  83. // the user's credit balance info.
  84. - (void)didFailToReceiveOfferwallCreditsWithError:(NSError *)error {
  85. NSLog(@"%s",__PRETTY_FUNCTION__);
  86. //收集错误日志上报服务器.
  87. self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
  88. }
  89. @end