激励视频
优质
小牛编辑
192浏览
2023-12-01
1. 包含头文件
#import <AdHubSDK/AdHubSDK.h>
2. AdHubRewardBasedVideoAd 的初始化与请求
在需要导入广告的ViewController头文件中导入头文件并声明实例以及声明代理
#import <AdHubSDK/AdHubSDK.h>
@interface AdHubRewardedVideoViewController () <AdHubRewardedVideoDelegate>
@property (nonatomic, strong) AdHubRewardedVideo *rewardedVideo;
@end
创建和初始化广告
self.rewardedVideo = [[AdHubRewardedVideo alloc]initWithSpaceID:@"在平台申请的广告位ID" spaceParam:@""];
self.rewardedVideo.delegate = self;
// 设置当前的VC,用于广告位点击跳转
self.rewardedVideo.adHubRewardedVideoViewController = self;
[self.rewardedVideo ADH_loadRewardedVideoAd];
3. AdHubRewardBasedVideoAd 主要属性说明
@property (nonatomic, copy, readonly) NSString *spaceID;
@property (nonatomic, copy, readonly) NSString *spaceParam;
/**
用来接收激励视频广告读取和展示状态变化通知的 delegate
*/
@property (nonatomic, weak) id<AdHubRewardedVideoDelegate> delegate;
/**
adHubRewardedVideoViewController 展示view的控制器或者弹出落地页的需要的控制器,此参数不能为空
*/
@property (nonatomic, weak) UIViewController *adHubRewardedVideoViewController;
/**
初始化方法
@param spaceID 广告位 ID
@param spaceParam 广告位参数 可填写任意字符串
@return 激励视频广告对象
*/
- (instancetype)initWithSpaceID:(NSString *)spaceID
spaceParam:(NSString *)spaceParam NS_DESIGNATED_INITIALIZER;
/**
请求加载激励视频广告
*/
- (void)ADH_loadRewardedVideoAd;
/**
激励视频展示,确保广告加载成功后调用
*/
- (void)ADH_showRewardedVideoAd;
4. AdHubRewardBasedVideoAdDelegate 的方法说明
/**
激励视频物料展现
*/
- (void)ADH_rewardedVideoDidReceiveAd:(AdHubRewardedVideo *)adHubRewardedVideo;
/**
激励展现并开始播放视频
*/
- (void)ADH_rewardedVideoDidStartPlay:(AdHubRewardedVideo *)adHubRewardedVideo;
/**
激励视频点击
*/
- (void)ADH_rewardedVideoDidClick:(AdHubRewardedVideo *)adHubRewardedVideo;
/**
激励视频消失
*/
- (void)ADH_rewardedVideoDidDismissScreen:(AdHubRewardedVideo *)adHubRewardedVideo;
/**
激励视频请求失败
*/
- (void)ADH_rewardedVideo:(AdHubRewardedVideo *)adHubRewardedVideo didFailToLoadAdWithError:(AdHubRequestError *)error;
/**
激励视频奖励
如果有渠道时,此方法仅限用于给用户发放奖励回调,奖励内容不可用。
@param reward 奖励内容 JSON字符串,自行解析
*/
- (void)ADH_rewardedVideo:(AdHubRewardedVideo *)adHubRewardedVideo didRewardUserWithReward:(NSObject *)reward;