Skip to main content

原生横幅(v6.4+)

  • 接入TradPlus SDK
  • 初始化TradPlus SDK
  • 在TradPlus后台创建原生广告位 选择原生横幅
  1. 初始化
#import <TradPlusAds/TradPlusNativeBanner.h>
//初始化广告位 frame大小可自行调整
self.nativeBanner = [[TradPlusNativeBanner alloc] init];
[self.nativeBanner setAdUnitID:@"您的广告位ID"];
//设置回调
self.nativeBanner.delegate = self;
  1. 加载广告
//sceneId为广告场景ID
[self.nativeBanner loadAdWithSceneId:nil];
  1. 显示广告
//sceneId为广告场景ID
[self.nativeBanner showWithSceneId:nil];
  1. 实现delegate方法,监听广告状态。 回调信息说明
///为三方提供rootviewController 用于点击广告后的操作
- (UIViewController *)viewControllerForPresentingModalView;
///AD加载完成
- (void)tpNativeBannerAdDidLoaded:(NSDictionary *)adInfo;
///AD加载失败
- (void)tpNativeBannerAdLoadFailWithError:(NSError *)error;
///AD展现
- (void)tpNativeBannerAdImpression:(NSDictionary *)adInfo;
///AD展现失败
- (void)tpNativeBannerAdShow:(NSDictionary *)adInfo didFailWithError:(NSError *)error;
///AD被点击
- (void)tpNativeBannerAdClicked:(NSDictionary *)adInfo;
///bidding开始
- (void)tpNativeBannerAdBidStart:(NSDictionary *)adInfo;
///bidding结束
- (void)tpNativeBannerAdBidEnd:(NSDictionary *)adInfo success:(BOOL)success;
///开始加载
- (void)tpNativeBannerAdLoadStart:(NSDictionary *)adInfo;
//多缓存情况下,当每个广告源加载成功后会都会回调一次。
- (void)tpNativeBannerAdOneLayerLoaded:(NSDictionary *)adInfo;
//多缓存情况下,当每个广告源加载失败后会都会回调一次。
- (void)tpNativeBannerAdOneLayerLoad:(NSDictionary *)adInfo didFailWithError:(NSError *)error;
///加载流程全部结束
- (void)tpNativeBannerAdAllLoaded:(BOOL)success;

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

RenderingViewClass,继承UIView,可参照 Demo 需要在load前关闭自动显示

//关闭自动显示
self.nativeBanner.autoShow = NO;
//sceneId为广告场景ID
[self.nativeBanner showWithRenderingViewClass:[RenderingViewClass class] sceneId:nil];

自定义view方式(可选)#

需要在load前关闭自动显示

//关闭自动显示
self.nativeBanner.autoShow = NO;
NativeBannerTemplate *adView = [[NSBundle mainBundle] loadNibNamed:@"NativeBannerTemplate" owner:self options:nil].lastObject;
adView.frame = self.adView.bounds;
//自行设置渲染元素 以及 元素是否可点击
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 setAdChoiceImageView:adView.adChoiceImageView canClick:YES];
[nativeRenderer setAdView:adView canClick:YES];
[self.nativeBanner showWithRenderer:nativeRenderer sceneId:nil];

注意:Facebook MyTarget 有专门的原生横幅广告,其他的在三方后台申请自渲染类型的原生广告,