前提条件

  • 接入UNAD SDK

  • 初始化UNAD SDK

  • 在UNAD后台创建插屏广告位

UNADInterstitialAd 广告集成

1.添加头文件并实现代理接口
#import <UNAD/UNAD.h>
@interface InterstitialViewController ()<UNADInterstitialAdDelegate>
2.添加⼀个 UNADInterstitialAd的属性
@property(nonatomic, strong)  UNADInterstitialAd *interstitialAD;
3.创建插屏广告对象并加载广告
  self.interstitialAD = [[UNADInterstitialAd alloc]initWithUnitID:UNAD_TEST_UNIT_ID];
  self.interstitialAD.delegate = self;
  self.interstitialAD.enableAudio = NO;//关闭视频声音,海外部分广告无法关闭
  [self.interstitialAD loadAd];
4.实现delegate方法,监听广告状态

/**
 广告已经加载
 */
- (void)interstitialAdLoaded:(UNADInterstitialAd *)interstitial
{
    _statusLabel.text = @"广告已经加载";
}
/**
 广告加载失败
 */
- (void)interstitialAd:(UNADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error
{
    NSString *message =   [ NSString stringWithFormat:@"广告加载失败:%@",error.localizedDescription];
    _statusLabel.text = message;
}
/**
 广告显示
 */
- (void)interstitialAdShown:(UNADInterstitialAd *)interstitial
{
    _statusLabel.text = @"广告显示";
}
/**
 广告点击
 */
- (void)interstitialAdClicked:(UNADInterstitialAd *)interstitial
{
    _statusLabel.text = @"广告被点击";
}
/**
 广告关闭
 */
- (void)interstitialAdDismissed:(UNADInterstitialAd *)interstitial
{
    _statusLabel.text = @"广告已关闭,请重新加载";
}
5.展示广告
   [self.interstitialAD showAdFromRootViewController:self];

results matching ""

    No results matching ""