Interstitials
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/TradPlusAdInterstitial.h>
self.interstitial = [[TradPlusAdInterstitial alloc] init];
[self.interstitial setAdUnitID:@"Your Ad Unit ID"];
self.interstitial.delegate = self;
[self.interstitialAd loadAd];
2. Show Interstitial Ad
- Call the
isAdReady
method to check if there is an available ad. When there is an available ad, call theshowAdWithSceneId:
method to display the ad. - sceneId is the Ad Scene ID. The default is nil.
if (self.interstitialAd.isAdReady)
{
[self.interstitial showAdWithSceneId:nil];
}
3. Register TradPlusADInterstitialDelegate 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)tpInterstitialAdLoaded:(NSDictionary *)adInfo;
//Ad loading failed
//tpInterstitialAdOneLayerLoaded:didFailWithError:returns the error message of the third-party source
- (void)tpInterstitialAdLoadFailWithError:(NSError *)error;
//Ad show succeeded. Valid show recognized by the third-party
- (void)tpInterstitialAdImpression:(NSDictionary *)adInfo;
//Ad show failed
- (void)tpInterstitialAdShow:(NSDictionary *)adInfo didFailWithError:(NSError *)error;
//Ad clicked
- (void)tpInterstitialAdClicked:(NSDictionary *)adInfo;
//Ad closed
- (void)tpInterstitialAdDismissed:(NSDictionary *)adInfo;
4. Integration Reference
Reference: TradPlusAdInterstitialViewController