Skip to main content

原生拼接开屏(v6.4+)

一、简介#

主要介绍在iOS项目中如何集成 TradPlus SDK的原生拼接开屏广告:

原生拼接开屏

  • 基于原生广告拼接开屏
  • 创建广告位时,样式选择选择原生广告,模版选择原生拼接开屏。
  • 如果三方提供的是模版类型的广告,不支持调整素材的位置。

二、集成说明#

  1. 初始化
#import <TradPlusAds/TradPlusNativeSplash.h>
//初始化广告位
self.splashAdView = [[TradPlusNativeSplash alloc] init];
[self.splashAdView setAdUnitID:@"您的广告位ID"];
//设置回调
self.splashAdView.delegate = self;
  1. 加载广告
[self.splashAdView loadAd];
  1. 显示广告
[self.splashAdView showInWindow:window];

v6.4增加 设置添加到指定view上

[self.splashAdView showInSubView:subview];
  1. 实现delegate方法,监听广告状态。 回调信息说明
///为三方提供rootviewController 用于点击广告后的操作
- (UIViewController *)viewControllerForPresentingModalView;
///AD加载完成
- (void)tpNativeSplashAdDidLoaded:(NSDictionary *)adInfo;
///AD加载失败
- (void)tpNativeSplashAdLoadFailWithError:(NSError *)error;
///AD展现
- (void)tpNativeSplashAdImpression:(NSDictionary *)adInfo;
///AD展现失败
- (void)tpNativeSplashAdShow:(NSDictionary *)adInfo didFailWithError:(NSError *)error;
///AD被点击
- (void)tpNativeSplashAdClicked:(NSDictionary *)adInfo;
///关闭
- (void)tpNativeSplashAdClosed:(NSDictionary *)adInfo;
///bidding开始
- (void)tpNativeSplashAdBidStart:(NSDictionary *)adInfo;
///bidding结束
- (void)tpNativeSplashAdBidEnd:(NSDictionary *)adInfo success:(BOOL)success;
///开始加载
- (void)tpNativeSplashAdLoadStart:(NSDictionary *)adInfo;
//多缓存情况下,当每个广告源加载成功后会都会回调一次。
- (void)tpNativeSplashAdOneLayerLoaded:(NSDictionary *)adInfo;
//多缓存情况下,当每个广告源加载失败后会都会回调一次。
- (void)tpNativeSplashAdOneLayerLoad:(NSDictionary *)adInfo didFailWithError:(NSError *)error;
///加载流程全部结束
- (void)tpNativeSplashAdAllLoaded:(BOOL)success;
///点击了跳过
- (void)tpNativeSplashAdClickSkip:(NSDictionary *)adInfo;
///跳过按钮显示
- (void)tpNativeSplashAdShowSkip:(NSDictionary *)adInfo;
///倒计时
- (void)tpNativeSplashAdCountDown:(NSDictionary *)adInfo progress:(NSInteger)progress;

自定义模版方式(可选)#

RenderingViewClass,继承UIView,可参照 Demo

[self.splashAdView showWithRenderingViewClass:[RenderingViewClass class] window:window];

v6.4增加 设置添加到指定view上

[self.splashAdView showWithRenderingViewClass:[RenderingViewClass class] subView:subView];

自定义view方式(可选)#

TPNativeTemplate *adView = [[NSBundle mainBundle] loadNibNamed:@"TPNativeTemplate" owner:self options:nil].lastObject;
adView.frame = [UIScreen mainScreen].bounds;
[adView layoutIfNeeded];
//自行设置渲染元素 以及 元素是否可点击
TradPlusNativeRenderer *nativeRenderer = [[TradPlusNativeRenderer alloc] init];
[nativeRenderer setTitleLable:adView.titleLabel canClick:YES];
[nativeRenderer setTextLable:adView.textLabel canClick:YES];
[nativeRenderer setCtaLable:adView.ctaLabel canClick:YES];
[nativeRenderer setIconView:adView.iconImageView canClick:YES];
[nativeRenderer setMainImageView:adView.mainImageView canClick:YES];
[nativeRenderer setAdChoiceImageView:adView.adChoiceImageView canClick:YES];
[nativeRenderer setAdView:adView canClick:YES];
[self.splashAdView showWithRenderer:nativeRenderer window:window];

v6.4增加 设置添加到指定view上

TPNativeTemplate *adView = [[NSBundle mainBundle] loadNibNamed:@"TPNativeTemplate" owner:self options:nil].lastObject;
adView.frame = subView.bounds;
[adView layoutIfNeeded];
//自行设置渲染元素 以及 元素是否可点击
TradPlusNativeRenderer *nativeRenderer = [[TradPlusNativeRenderer alloc] init];
[nativeRenderer setTitleLable:adView.titleLabel canClick:YES];
[nativeRenderer setTextLable:adView.textLabel canClick:YES];
[nativeRenderer setCtaLable:adView.ctaLabel canClick:YES];
[nativeRenderer setIconView:adView.iconImageView canClick:YES];
[nativeRenderer setMainImageView:adView.mainImageView canClick:YES];
[nativeRenderer setAdChoiceImageView:adView.adChoiceImageView canClick:YES];
[nativeRenderer setAdView:adView canClick:YES];
[self.splashAdView showWithRenderer:nativeRenderer subView:subView];