插屏
优质
小牛编辑
137浏览
2023-12-01
1. 包含头文件
#import <AdHubSDK/AdHubSDK.h>
2. AdHubInterstitial 的创建和初始化
在需要导入广告的ViewController头文件中导入头文件并声明实例以及声明代理
#import <AdHubSDK/AdHubSDK.h>
@interface AdHubInterstitialsViewController () <AdHubInterstitialDelegate>
@property (nonatomic, strong) AdHubInterstitial *interstitial;
@end
创建和初始化广告
// 初始化广告位
self.interstitial = [[AdHubInterstitial alloc]initWithSpaceID:@"在平台申请的广告位ID" spaceParam:@""];
// 设置当前的VC,用于广告位点击跳转d,当需要在Tabbar页面弹出时,根视图须设置为Tabbar,否则会影响广告后续点击,所以最好默认使用[UIApplication sharedApplication].delegate.window.rootViewController
self.interstitial.adhubInterstitialController = [UIApplication sharedApplication].delegate.window.rootViewController;
self.interstitial.delegate = self;
[self.interstitial ADH_loadInterstitialAd];
3. AdHubInterstitial 主要属性说明
/**
spaceID广告位ID
spaceParam备用参数
*/
@property (nonatomic, copy, readonly) NSString *spaceID;
@property (nonatomic, copy, readonly) NSString *spaceParam;
/**
用来接收 Interstitial 广告读取和展示状态变化通知的 delegate
*/
@property (nonatomic, weak) id<AdHubInterstitialDelegate> delegate;
/**
adhubInterstitialController 展示view的控制器或者弹出落地页的需要的控制器,此参数不能为空
详解:[必选]开发者需传入用来弹出目标页的ViewController,一般为当前ViewController
当需要在Tabbar页面弹出时,根视图须设置为Tabbar,否则会影响广告后续点击
*/
@property (nonatomic, weak) UIViewController *adhubInterstitialController;
/**
初始化方法
@param spaceID 广告位 ID
@param spaceParam 广告位参数 可填写任意字符串
@return Interstitial 广告对象
*/
- (instancetype)initWithSpaceID:(NSString *)spaceID spaceParam:(NSString *)spaceParam;
/**
Interstitial 加载
*/
- (void)ADH_loadInterstitialAd;
/**
Interstitial 展示,确保广告加载成功后调用
*/
- (void)ADH_showInterstitialAd;
4. AdHubInterstitialDelegate 的方法说明
/**
插屏加载成功
*/
- (void)ADH_interstitialDidReceiveAd:(AdHubInterstitial *)adHubInterstitial;
/**
插屏展现
*/
- (void)ADH_interstitialDidPresentScreen:(AdHubInterstitial *)adHubInterstitial;
/**
插屏点击
*/
- (void)ADH_interstitialDidClick:(AdHubInterstitial *)adHubInterstitial;
/**
插屏消失&&关闭
*/
- (void)ADH_interstitialDidDismissScreen:(AdHubInterstitial *)adHubInterstitial;
/**
插屏请求失败
*/
- (void)ADH_interstitial:(AdHubInterstitial *)adHubInterstitial didFailToLoadAdWithError:(AdHubRequestError *)error;