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

  • Objective-C
objc
#import <CartySDK/CartySDK.h>

self.interstitialAd = [[CTInterstitialAd alloc] init];
self.interstitialAd.placementid = @"<your-placement-id>";
self.interstitialAd.delegate = self;
[self.interstitial loadAd];
  • Swift
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.

  • Objective-C
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
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:

  • Objective-C
objc
if(self.interstitialAd.isReady)
{
    [self.interstitialAd showAd:self];
}
  • Swift
swift
if(interstitialAd.isReady())
{
    interstitialAd.show(self)
}

Other

Mute

Make sure make this call before load

  • Objective-C
objc
self.interstitialAd.isMute = YES;
  • Swift
swift
interstitialAd.isMute = true

Examples on GitHub