Interstitial ads
This is an archived version of the documentation. Actual documentation for all platforms can be found here.
An interstitial ad is a configurable ad that covers the entire screen and responds to clicks.
To enable advertising:
Add the import:
import YandexMobileAds
#import <YandexMobileAds/YandexMobileAds.h>
Create
@property
where the link to the banner ad will be stored:var interstitialAd: YMAInterstitialAd!
@property (nonatomic, strong) YMAInterstitialAd *interstitialAd;
Perform initialization and pre-loading of the ad. This must be performed after displaying the app interface.
Optionally, you can use the YMAAdRequest class to transmit the data for targeting. For an example of using the class, see Interstitial ads.
interstitialAd = YMAInterstitialAd(adUnitID: “<AdUnitID>”) interstitialAd.delegate = self interstitialAd.load()
self.interstitialAd = [[YMAInterstitialAd alloc] initWithAdUnitID:<your unique AdUnitId>]; self.interstitialAd.delegate = self; [self.interstitialAd load];
AdUnitId
is a unique identifier in R-M-XXXXXX-Y format, which is assigned in the Partner Interface.In addition,
self
must conform to the YMAInterstitialAdDelegate protocol. The ad must be pre-loaded in the same orientation as it will be shown (otherwise, the ad won't be shown because the banner size doesn't match the screen size).Start displaying ads by using this method:
func interstitialAdDidLoad(_ interstitialAd: YMAInterstitialAd) { interstitialAd.present(from: self) }
- (void)interstitialAdDidLoad:(YMAInterstitialAd *)interstitialAd { [interstitialAd presentFromViewController:self]; }
You can optionally enable logging by using the +enableLogging method. If an impression wasn't registered, a message appears in the console.
func interstitialAdDidFail(toLoad interstitialAd: YMAInterstitialAd, error: Error)
func interstitialAdDidFail(toPresent interstitialAd: YMAInterstitialAd, error: Error)
- (void)interstitialAdDidFailToLoad:(YMAInterstitialAd *)interstitialAd error:(NSError *)error;
- (void)interstitialAdDidFailToPresent:(YMAInterstitialAd *)interstitialAd error:(NSError *)error;
For error descriptions, see YMAAdErrorCode.
let yandexAdUnitID = "demo-interstitial-yandex"
let adMobAdUnitID = "demo-interstitial-admob"
let appLovinAdUnitID = "demo-interstitial-applovin"
let ironSourceAdUnitID = "demo-interstitial-ironsource"
let mintegralAdUnitID = "demo-interstitial-mintegral"
let myTargetAdUnitID = "demo-interstitial-mytarget"
let startAppAdUnitID = "demo-interstitial-startapp"
let unityAdsAdUnitID = "demo-interstitial-unityads"