1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // FqIronsourceVideo.m
- // QQQ
- //
- // Created by Mgs on 2020/12/7.
- //
- #import "FqIronsourceVideo.h"
- #import "XSNetwork.h"
- @interface FqIronsourceVideo()<ISRewardedVideoDelegate>
- @property(nonatomic,assign)BOOL isVideoReadly;
- @property(nonatomic,assign)BOOL giveReward;
- @property(nonatomic,strong)void(^videoCallback)(BOOL);
- @end
- @implementation FqIronsourceVideo
- -(instancetype)init{
- if (self = [super init]) {
- self.agentName = @"IronSource"; //平台名称
- NSDictionary *infos = [[NSBundle mainBundle] infoDictionary];
- self.adUnitId = [infos objectForKey:@"ironsource-video-unitId"];
- self.type = @"Rewarded"; //广告类型
- self.unitAdId = @""; //广告组ID
- [IronSource setRewardedVideoDelegate:self];
- self.isVideoReadly = false;
- self.giveReward = false;
- }
- return self;
- }
- -(BOOL)isAdReady{
- return [IronSource hasRewardedVideo];
- }
- -(void)openVideo:(NSString *)adName callback:(void (^)(BOOL))callback{
-
- self.adId = adName;
- self.videoCallback = callback;
- dispatch_async(dispatch_get_main_queue(), ^{
- UIViewController *vc = [GMTools getViewControl];
- [IronSource showRewardedVideoWithViewController:vc placement:adName];
- });
-
- //数据上报
- [XSNetwork adRecord:@"quest" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
-
- }
- - (void)rewardedVideoHasChangedAvailability:(BOOL)available{
- self.isVideoReadly = available;
- }
- - (void)didReceiveRewardForPlacement:(ISPlacementInfo *)placementInfo{
- self.giveReward = true;
- }
- - (void)rewardedVideoDidFailToShowWithError:(NSError *)error{
-
- //收集错误日志上报服务器.
- self.errorMsg = [NSString stringWithFormat:@"code=%ld,domain=%@,describe=%@",(long)error.code,error.domain,error.userInfo];
-
- if (self.videoCallback) {
- self.giveReward = false;
- self.videoCallback(self.giveReward);
- }
- }
- - (void)rewardedVideoDidOpen{
-
- [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)rewardedVideoDidClose{
-
- [XSNetwork adRecord:@"close" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
- if (self.videoCallback) {
- self.videoCallback(self.giveReward);
- self.giveReward = false;
- }
- }
- - (void)rewardedVideoDidStart{
-
- }
- - (void)rewardedVideoDidEnd{
-
- }
- - (void)didClickRewardedVideo:(ISPlacementInfo *)placementInfo{
-
- [XSNetwork adRecord:@"click" spaceId:self.adId agentName:self.agentName medium:self.medium adUnitId:self.adUnitId type:self.type unitAdId:self.unitAdId errorMsg:self.errorMsg];
-
- }
- @end
|