Skip to main content

Native Ads

1. Load an ad#

  • It takes some time to load ads, so it is recommended to pre-load ads before displaying them.
  • AdUnitID is the Ad Unit ID created in the TradPlus backend. SDK will fetch the configuration and request ads according to the Ad Unit ID.
#import <TradPlusAds/TradPlusAdNative.h>
self.nativeAd = [[TradPlusAdNative alloc] init];
[self.nativeAd setAdUnitID:@"Your Ad Unit ID"];
//Set the loading size of native template ads (optional)
[self.nativeAd setTemplateRenderSize:CGSizeMake(320, 200)];
self.nativeAd.delegate = self;
[self.nativeAd loadAd];

2. Show Native Ad#

  • Developers can implement custom layouts through RenderingViewClass, and ad materials are spliced into ad styles through this layout. Refer to TPNativeTemplate
  • The rendered ads will be added to the adView passed in
  • sceneId is the Ad Scene ID, which is nil by default.
[self.nativeAd showADWithRenderingViewClass:[RenderingViewClass class] subview:self.adView sceneId:nil];

3. Register TradPlusADNativeDelegate Callback#

  • Ad event callbacks need to be registered before displaying an ad. Get callbacks for ad loading, ad show, ad click, ad close, etc.
//Ad loading is complete, and the first ad source is loaded successfully. The loading process will only be called once
- (void)tpNativeAdLoaded:(NSDictionary *)adInfo;
//Ad loading failed
///tpNativeAdOneLayerLoad:didFailWithError:Returns the error message of the third party source
- (void)tpNativeAdLoadFailWithError:(NSError *)error;
//Ad show succeeded. Valid show recognized by the third party
- (void)tpNativeAdImpression:(NSDictionary *)adInfo;
//Ad show failed
- (void)tpNativeAdShow:(NSDictionary *)adInfo didFailWithError:(NSError *)error;
//Ad clicked
- (void)tpNativeAdClicked:(NSDictionary *)adInfo;

4. Integration Reference#

Reference: TradPlusAdNativeViewController