Loading an Interstitial Ad
To load an interstitial ad, instantiate an MAInterstitialAd
object that corresponds to your ad unit and call its loadAd()
method.
Implement MAAdDelegate
so that you are notified when your ad is ready.
This also notifies you of other ad-related events.
#import " ExampleViewController.h "
#import < AppLovinSDK/AppLovinSDK.h >
@interface ExampleViewController()<MAAdDelegate>
@property ( nonatomic , strong ) MAInterstitialAd * interstitialAd;
@property ( nonatomic , assign ) NSInteger retryAttempt;
@implementation ExampleViewController
- ( void ) createInterstitialAd
self .interstitialAd = [[MAInterstitialAd alloc ] initWithAdUnitIdentifier : @" «ad-unit-ID» " ];
self . interstitialAd . delegate = self ;
[ self .interstitialAd loadAd ];
#pragma mark - MAAdDelegate Protocol
- ( void ) didLoadAd : (MAAd * ) ad
// Interstitial ad is ready to be shown. '[self.interstitialAd isReady]' will now return 'YES'
- ( void ) didFailToLoadAdForAdUnitIdentifier : ( NSString * ) adUnitIdentifier withError : (MAError * ) error
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
NSInteger delaySec = pow( 2 , MIN( 6 , self . retryAttempt )) ;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^ {
[ self .interstitialAd loadAd ];
- ( void ) didDisplayAd : (MAAd * ) ad {}
- ( void ) didClickAd : (MAAd * ) ad {}
- ( void ) didHideAd : (MAAd * ) ad
// Interstitial ad is hidden. Pre-load the next ad
[ self .interstitialAd loadAd ];
- ( void ) didFailToDisplayAd : (MAAd * ) ad withError : (MAError * ) error
// Interstitial ad failed to display. AppLovin recommends that you load the next ad.
[ self .interstitialAd loadAd ];
class ExampleViewController: UIViewController , MAAdDelegate
var interstitialAd: MAInterstitialAd !
func createInterstitialAd ()
interstitialAd = MAInterstitialAd ( adUnitIdentifier : " «ad-unit-ID» " )
interstitialAd. delegate = self
// MARK: MAAdDelegate Protocol
// Interstitial ad is ready to be shown. 'interstitialAd.isReady' will now return 'true'
func didFailToLoadAd ( forAdUnitIdentifier adUnitIdentifier : String , withError error : MAError )
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
let delaySec = pow ( 2.0 , min ( 6.0 , retryAttempt ))
DispatchQueue. main . asyncAfter ( deadline : . now () + delaySec ) {
self . interstitialAd . load ()
func didDisplay ( _ ad : MAAd ) {}
func didClick ( _ ad : MAAd ) {}
// Interstitial ad is hidden. Pre-load the next ad
func didFail ( toDisplay ad : MAAd, withError error : MAError )
// Interstitial ad failed to display. AppLovin recommends that you load the next ad.
Showing an Interstitial Ad
To show an interstitial ad, call showAd()
on the MAInterstitialAd
object that you instantiated:
if ( [ self .interstitialAd isReady ] )
[ self .interstitialAd showAd ];
if interstitialAd.isReady