123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- //
- // ISAdOfferWall.m
- // XenonSDK
- //
- // Created by fq on 2020/12/25.
- // Copyright © 2020 SAGESSE. All rights reserved.
- //
- #import "ISAdOfferWall.h"
- #import <IronSource/IronSource.h>
- #import "XSNetwork.h"
- @interface ISAdOfferWall()<ISOfferwallDelegate>
- //是否加载好
- @property (nonatomic, assign)BOOL ready;
- @end
- @implementation ISAdOfferWall
- - (instancetype)init
- {
- self = [super init];
- if (self) {
-
- self.ready = NO;
- self.adId = @""; //广告位名称
- self.agentName = @"ironsource"; //平台名称
- self.medium = @""; //中介
- self.adUnitId = @"Rewarded"; //原平台单元id
- self.type = @"Rewarded"; //广告类型
- self.unitAdId = @""; //广告组ID
- self.errorMsg = @""; //错误信息
-
- //init
- [IronSource setOfferwallDelegate:self];
-
- }
- return self;
- }
- - (BOOL)isReady {
- return self.ready;
- }
- - (void)play:(NSString *)adId callback:(void (^)(int))back {
- [XSNetwork adRecord:@"quest" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
-
- if (self.ready) {
- UIWindow *window = [self currentWindow];
- if (window) {
- [IronSource showOfferwallWithViewController:window.rootViewController];
- }
- }
- }
- #pragma mark - ISOfferwallDelegate
- // This method gets invoked after the availability of the Offerwall changes.
- - (void)offerwallHasChangedAvailability:(BOOL)available {
- NSLog(@"%s", __PRETTY_FUNCTION__);
- NSLog(@"ironsource ISAdRewarded rewardedVideoHasChangedAvailability :%d",available);
- self.ready = available;
- }
- // This method gets invoked each time the Offerwall loaded successfully.
- - (void)offerwallDidShow {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- [XSNetwork adRecord:@"show" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
-
- }
- // This method gets invoked after a failed attempt to load the Offerwall.
- // If it does happen, check out 'error' for more information and consult our
- // Knowledge center.
- - (void)offerwallDidFailToShowWithError:(NSError *)error {
- NSLog(@"%s",__PRETTY_FUNCTION__);
-
- //收集错误日志上报服务器.
- self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
- }
- // This method gets invoked after the user had clicked the little
- // 'x' button at the top-right corner of the screen.
- - (void)offerwallDidClose {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- [XSNetwork adRecord:@"close" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
- }
- // This method will be called each time the user has completed an offer.
- // All relative information is stored in 'creditInfo' and it is
- // specified in more detail in 'SupersonicOWDelegate.h'.
- // If you return NO the credit for the last offer will be added to
- // Everytime you return 'NO' we aggragate the credit and return it all
- // at one time when you return 'YES'.
- - (BOOL)didReceiveOfferwallCredits:(NSDictionary *)creditInfo {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- NSLog(@"didReceiveOfferwallCredits:%@",creditInfo);
- return YES;
- }
- // This method get invoked when the ‘-getOWCredits’ fails to retrieve
- // the user's credit balance info.
- - (void)didFailToReceiveOfferwallCreditsWithError:(NSError *)error {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- //收集错误日志上报服务器.
- self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
-
- }
- @end
|