Back to top

Interstitial Ad Units

Last Updated on: 13 Jul, 2022

Create Interstitial Ad Unit

INFO

If you miss to Initialize the SDK, this method will fail to return a response.

To create a new interstitial ad, create an MesonInterstitial object.

Swift

var interstitialAd: MesonInterstitial = MesonInterstitial.init(adUnitId: "AD_UNIT_ID", delegate: self)

Objective-C

MesonInterstitial *interstitialAd = [[MesonInterstitial alloc] initWithAdUnitId:@"AD_UNIT_ID" delegate:self]; 

Register for Postbacks

Track the ad lifecycle for interstitial ads. All the available events for interstitial ads are listed below.

Swift

extension <Class> : MesonInterstitialDelegate {
  
  func mesonInterstitialDidLoad(_ interstitialAd: MesonInterstitial) {
  }
  
  func mesonInterstitialDidFailToLoad(_ interstitialAd: MesonInterstitial, error: Error) {
  }
  
  func mesonInterstitialImpression(_ interstitialAd: MesonInterstitial, adData: MesonAdData?) {
  }
  
  func mesonInterstitialDidFailToDisplay(_ interstitialAd: MesonInterstitial, error: Error) {
  }
  
  func mesonInterstitialUserWillLeaveApplication(_ interstitialAd: MesonInterstitial) {
  }
  
  func mesonInterstitialWillDisplay(_ interstitialAd: MesonInterstitial) {
  }
  
  func mesonInterstitialDidDisplay(_ interstitialAd: MesonInterstitial) {
  }
  
  func mesonInterstitialWillDismiss(_ interstitialAd: MesonInterstitial) {
  }
  
  func mesonInterstitialDidDismiss(_ interstitialAd: MesonInterstitial) {
  }
  
  func mesonInterstitialDidClick(_ interstitial: MesonInterstitial, params: [String : Any]?) {
  }

}

Objective-C

- (void)mesonInterstitialDidLoad:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialDidFailToLoad:(MesonInterstitial *)interstitialAd error:(NSError *)error {
}

- (void)mesonInterstitialDidFailToDisplay:(MesonInterstitial *)interstitialAd error:(NSError *)error{
}

- (void)mesonInterstitialImpression:(MesonInterstitial *)interstitialAd adData:(MesonAdData *)adData{
}

- (void)mesonInterstitialDidClick:(MesonInterstitial *)interstitial params:(NSDictionary<NSString *,id> *)params {
}

- (void)mesonInterstitialUserWillLeaveApplication:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialWillDisplay:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialDidDisplay:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialDidDismiss:(MesonInterstitial *)interstitialAd {
}

- (void)mesonInterstitialWillDismiss:(MesonInterstitial *)interstitialAd {
}

Load Ad

The publisher can request an interstitial ad by invoking this method. This will request an ad from all demand sources, select a winner, and make it available on the SDK.

Swift

interstitialAd.load()

Objective-C

[interstitialAd load];

Show Ad

The ad is available when the load is called. It is shown to the user when the show method is called. It is recommended to check isReady method and then call the show method.

Swift

interstitialAd.show(from: <UIViewController>)

Objective-C

[interstitialAd showFromViewController:<ViewController>];