Skip to main content

原生拼接开屏

原生拼接开屏#

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

集成说明#

1. 初始化#

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

2. 加载广告#

[self.splashAdView loadAd];

3. 显示广告#

[self.splashAdView showInWindow:window];
  • 设置添加到指定view上
[self.splashAdView showInSubView:subview];

4.监听回调#

  • 回调信息说明

  • tpNativeSplashAdLoadFailWithError:返回的是TP封装的错误信息:详见: 错误码说明

  • tpNativeSplashAdOneLayerLoad:didFailWithError: 返回三方源的错误信息

  • 以下回调接口已废弃v7.6.0+

- (void)tpNativeSplashAdBidEnd:(NSDictionary *)adInfo success:(BOOL)success DEPRECATED_MSG_ATTRIBUTE("Please use tpNativeSplashAdBidEnd:error:");
- (void)tpNativeSplashAdLoadStart:(NSDictionary *)adInfo DEPRECATED_MSG_ATTRIBUTE("Please use tpNativeSplashAdOneLayerStartLoad:");

回调接口及说明

///为三方提供rootviewController 用于点击广告后的操作
- (UIViewController *)viewControllerForPresentingModalView;
///AD加载完成 首个广告源加载成功时回调 一次加载流程只会回调一次
- (void)tpNativeSplashAdDidLoaded:(NSDictionary *)adInfo;
///AD加载失败
///tpNativeSplashAdOneLayerLoad:didFailWithError:返回三方源的错误信息
- (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;
@optional
///v7.6.0+新增 开始加载流程
- (void)tpNativeSplashAdStartLoad:(NSDictionary *)adInfo;
///当每个广告源开始加载时会都会回调一次。
///v7.6.0+新增。替代原回调接口:tpNativeSplashAdLoadStart:(NSDictionary *)adInfo;
- (void)tpNativeSplashAdOneLayerStartLoad:(NSDictionary *)adInfo;
///v8.7.0+新增
///调用load之后如果收到此回调,说明广告位仍处于加载状态,无法触发新的一轮广告加载。
- (void)tpNativeSplashAdIsLoading:(NSDictionary *)adInfo;
///bidding开始
- (void)tpNativeSplashAdBidStart:(NSDictionary *)adInfo;
///bidding结束 error = nil 表示成功
- (void)tpNativeSplashAdBidEnd:(NSDictionary *)adInfo error:(NSError *)error;
///当每个广告源加载成功后会都会回调一次。
- (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;
///开始播放 v7.8.0+
- (void)tpNativeSplashAdVideoPlayStart:(NSDictionary *)adInfo;
///播放结束 v7.8.0+
- (void)tpNativeSplashAdVideoPlayEnd:(NSDictionary *)adInfo;

5. 接入参考#

参考:TradPlusAdNativeSplashViewController

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

RenderingViewClass,继承UIView,可参照 Demo

[self.splashAdView showWithRenderingViewClass:[RenderingViewClass class] window:window];
  • 设置添加到指定view上
[self.splashAdView showWithRenderingViewClass:[RenderingViewClass class] subView:subView];

7.自定义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];
  • 设置添加到指定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];