Skip to content

Interstitia Ads

Interstitial ads are full-screen or full-page ads that temporarily cover an app’s interface. They’re typically shown at natural pauses or transition points—such as after completing a level in a game or when navigating between major views.

The following sections show you how to load and then show a interstitial ad.

Load an ad

To load an interstitial ad, instantiate an CTInterstitialAd object that corresponds to your ad unit and call its loadAd method

objc
#import <CartySDK/CartySDK.h>

self.interstitialAd = [[CTInterstitialAd alloc] init];
self.interstitialAd.placementid = @"<your-placement-id>";
self.interstitialAd.delegate = self;
[self.interstitial loadAd];
swift
import CartySDK

interstitialAd = CTInterstitialAd()
interstitialAd.placementid = "<your-placement-id>"
interstitialAd.delegate = self
interstitialAd.load()

Register for Callbacks

Implement CTInterstitialAdDelegate to listen to ad events.

objc
- (void)CTInterstitialAdDidLoad:(nonnull CTInterstitialAd *)ad {
    NSLog(@"Ad loaded");
}

- (void)CTInterstitialAdLoadFail:(nonnull CTInterstitialAd *)ad withError:(nonnull NSError *)error { 
	NSLog(@"Ad load fail: %@",error.localizedDescription);
}

- (void)CTInterstitialAdDidShow:(nonnull CTInterstitialAd *)ad { 
	NSLog(@"Ad did show");
}

- (void)CTInterstitialAdShowFail:(nonnull CTInterstitialAd *)ad withError:(nonnull NSError *)error { 
	NSLog(@"Ad show fail: %@",error.localizedDescription);
}

- (void)CTInterstitialAdDidClick:(nonnull CTInterstitialAd *)ad {
    NSLog(@"Ad did click");
}

- (void)CTInterstitialAdDidDismiss:(nonnull CTInterstitialAd *)ad {
    NSLog(@"Ad did close");
}
swift
func ctInterstitialAdDidLoad(_ ad: CTInterstitialAd) {
    print("Ad loaded")
}
    
func ctInterstitialAdLoadFail(_ ad: CTInterstitialAd, withError error: any Error) {
    print("Ad load fail \(error.localizedDescription)")
}
    
func ctInterstitialAdDidShow(_ ad: CTInterstitialAd) {
    print("Ad did show")
}
    
func ctInterstitialAdShowFail(_ ad: CTInterstitialAd, withError error: any Error) {
    print("Ad show fail \(error.localizedDescription)")
}
    
func ctInterstitialAdDidClick(_ ad: CTInterstitialAd) {
    print("Ad did click")
}
    
func ctInterstitialAdDidDismiss(_ ad: CTInterstitialAd) {
     print("Ad did close")
}

Display the ad

To show an interstitial ad, call showAd on the CTInterstitialAd object that you instantiated:

objc
if(self.interstitialAd.isReady)
{
    [self.interstitialAd showAd:self];
}
swift
if(interstitialAd.isReady())
{
    interstitialAd.show(self)
}

Other

Mute

Make sure make this call before load

objc
self.interstitialAd.isMute = YES;
swift
interstitialAd.isMute = true

Client-side bidding

After the ad loads successfully, you can obtain ecpm via the following API.

objc
self.interstitialAd.ecpm
swift
interstitialAd.ecpm

After winning the ad bid, call bidWin and pass in the second-highest bid from this bid.

objc
[self.interstitialAd bidWin:@"second_pirce"];
swift
interstitialAd.bidWin("second_pirce");

After an ad is lost, bidWin is called with the highest bid received in the auction.

objc
[self.interstitialAd bidLoss:@"top_price"];
swift
interstitialAd.bidLoss("top_price")

Examples on GitHub