Skip to main content

Banners

1. Load an ad

  • TradPlusAdBanner is a UIView itself, developers can adjust the position and size by themselves. Just add it to the specified UIView after creation.
  • It takes some time to load the ads, so it is recommended to pre-load the ads before displaying them.
  • AdUnitID is the ad unit ID created in the TradPlus backend, and the SDK will fetch the configuration and request the ad according to the ad unit ID.
  • The sceneId is the ad scene ID, which is nil by default.
#import <TradPlusAds/TradPlusAdBanner.h>
self.banner = [[TradPlusAdBanner alloc] init];
[self.banner setAdUnitID:@"Your ad unit ID"];
self.banner.delegate = self;
[self.adView addSubview:self.banner];
[self.banner loadAdWithSceneId:nil];

2. Show Banner Ad

  • After the ad is loaded successfully, it will automatically fill in the TradPlusAdBanner. No need to call the showWithSceneId: method.

3. Register TradPlusADBannerDelegate 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 loaded successfully, callback when the first ad source is loaded successfully. The loading process will only be called once
- (void)tpBannerAdLoaded:(NSDictionary *)adInfo;

//Ad loading failed
///tpBannerAdOneLayerLoad:didFailWithError:returns the error message of the third-party source
- (void)tpBannerAdLoadFailWithError:(NSError *)error;

//Ad show succeeded. Valid show recognized by the third party
- (void)tpBannerAdImpression:(NSDictionary *)adInfo;

//Ad show failed
- (void)tpBannerAdShow:(NSDictionary *)adInfo didFailWithError:(NSError *)error;

//Ad clicked
- (void)tpBannerAdClicked:(NSDictionary *)adInfo;

//////Provide rootviewController for third parties for operations after clicking on the Ad
- (nullable UIViewController *)viewControllerForPresentingModalView;

4. Integration Reference

Refer to: TradPlusAdBannerViewController