Interstitial Ad

1. Basic requirements

  • Add ​ADX iOS SDK to your project.

  • Use the Ad Unit ID issued for Interstitial Ads.

  • Before requesting an ad, SDK initialization must be done first.

    • SDK initialization should be called only once when the app launches and ad requests should be made after SDK initialization is complete.

    • For iOS 14 and later, request ads only after obtaining ATT (App Tracking Transparency) permission.

2. Implementation

  1. Instantiate an ADXInterstitialAd using the initWithAdUnitId: method and register the ADXInterstitialAdDelegate callbacks.

  2. Call loadAd to request an ad.

  3. Check whether an ad is available using isLoaded, and if so, display the ad with showAdFromRootViewController:

#import <ADXLibrary/ADXInterstitialAd.h>

@interface InterstitialViewController () <ADXInterstitialAdDelegate>

@property (strong) ADXInterstitialAd *interstitialAd;

@end

@implementation InterstitialViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.interstitialAd = [[ADXInterstitialAd alloc] 
        initWithAdUnitId:@"<ADX_INTERSTITIAL_AD_UNIT_ID>"];
    self.interstitialAd.delegate = self;
}

- (IBAction)loadAd:(id)sender {
    [self.interstitialAd loadAd];
}

- (IBAction)showAd:(id)sender {
    if (self.interstitialAd.isLoaded) {
        [self.interstitialAd showAdFromRootViewController:self];
    }
}

#pragma mark - ADXInterstitialAdDelegate

- (void)interstitialAdDidLoad:(ADXInterstitialAd *)interstitial {
    NSLog(@"interstitialAdDidLoad");
}

- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd didFailToLoadWithError:(NSError *)error {
    NSLog(@"interstitialAd:didFailToLoadWithError: %@", error);
}

- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd didFailToShowWithError:(NSError *)error {
    NSLog(@"interstitialAd:didFailToShowWithError: %@", error);
}

- (void)interstitialAdWillPresentScreen:(ADXInterstitialAd *)interstitialAd {
    NSLog(@"interstitialAdWillPresentScreen");
}

- (void)interstitialAdWillDismissScreen:(ADXInterstitialAd *)interstitialAd {
    NSLog(@"interstitialAdWillDismissScreen");
}

- (void)interstitialAdDidDismissScreen:(ADXInterstitialAd *)interstitialAd {
    NSLog(@"interstitialAdDidDismissScreen");
}

- (void)interstitialAdDidClick:(ADXInterstitialAd *)interstitialAd {
    NSLog(@"interstitialAdDidClick");
}

@end

3. Callback

You can receive interstitial ad events through the ADXInterstitialAdDelegate.

- (void)interstitialAdDidLoad:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAdWillPresentScreen:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAdWillDismissScreen:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAdDidDismissScreen:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAdDidClick:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd 
    didFailToLoadWithError:(NSError *)errorr;
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd 
    didFailToShowWithError:(NSError *)error;

4. Ad Revenue (paidEventHandler)

You can check the estimated ad revenue for ad impressions.

  • As shown in the example below, use paidEventHandler to check the estimated eCPM value.

  • Manually set values during mediation setup and actual values may be mixed, so it is recommended to treat this as an estimate.

  • The currency unit of eCPM is USD.

  • You can link ad revenue data with your MMP. For details, please refer to the SDK integration guides below:

#import <UIKit/UIKit.h>
#import <ADXLibrary/ADXInterstitialAd.h>
#import <FirebaseAnalytics/FirebaseAnalytics.h>
#import <AppsFlyerAdRevenue/AppsFlyerAdRevenue.h>

@interface InterstitialViewController () <ADXInterstitialAdDelegate>
@property (strong) ADXInterstitialAd *interstitialAd;
@end

@implementation InterstitialViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.interstitialAd = [[ADXInterstitialAd alloc] 
        initWithAdUnitId:@"<ADX_INTERSTITIAL_AD_UNIT_ID>"];
                        
    self.interstitialAd.delegate = self;    
        
    __weak typeof(self) weakSelf = self;
    self.interstitialAd.paidEventHandler = ^(double eCPM) {
        __strong typeof(self) strongSelf = weakSelf;
        if(!strongSelf) { return; }
        NSNumber * revenue = [NSNumber numberWithDouble:eCPM/1000];
        [strongSelf handleAdRevenue:revenue];
    };
}

- (void)handleAdRevenue:(NSNumber *)revenue {
    // 1) Firebase Analytics
    [FIRAnalytics logEventWithName:kFIREventAdImpression parameters: @{
        kFIRParameterAdPlatform: @"AD(X)",
        kFIRParameterAdFormat: @"InterstitialAd",
        kFIRParameterAdUnitName: @"ADX Interstitial Ad",
        kFIRParameterCurrency: @"USD",
        kFIRParameterValue: revenune
    }];
        
    // 2) AppsFlyer
    NSDictionary * adRevenueParams = @{
        @"AdUnitName" : @"ADX Interstitial Ad",
        @"AdType" : @"InterstitialAd",
    };
    
    AppsFlyerAdRevenue * appsFlyerAdRevenue = [AppsFlyerAdRevenue shared];
    [appsFlyerAdRevenue 
        logAdRevenueWithMonetizationNetwork:@"AD(X)"
        mediationNetwork:AppsFlyerAdRevenueMediationNetworkTypeCustom
        eventRevenue:revenune
        revenueCurrency:@"USD"
        additionalParameters:adRevenueParams];
}

#pragma mark - ADXInterstitialAdDelegate
- (void)interstitialAdDidLoad:(ADXInterstitialAd *)interstitial {}
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd didFailToLoadWithError:(NSError *)error {}
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd didFailToShowWithError:(NSError *)error {}
- (void)interstitialAdWillPresentScreen:(ADXInterstitialAd *)interstitialAd {}
- (void)interstitialAdWillDismissScreen:(ADXInterstitialAd *)interstitialAd {}
- (void)interstitialAdDidDismissScreen:(ADXInterstitialAd *)interstitialAd {}
- (void)interstitialAdDidClick:(ADXInterstitialAd *)interstitialAd {}

@end

Last updated

Was this helpful?