Interstitial ads

Warning.

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:

  1. Add the import:

    import YandexMobileAds
  2. Create @property where the link to the banner ad will be stored:

    var interstitialAd: YMAInterstitialAd!
  3. Perform ad initialization and pre-loading using the -loadWithRequest: method.

    Use the YMAAdRequest class to transmit the code received in the Adfox interface (for more information, see Help for Adfox).
    // Code from the Adfox interface for working with direct campaigns.
    var parameters = [String: String]()
    parameters["adf_ownerid"] = "<example>"
    parameters["adf_p1"] = "<example>"
    parameters["adf_p2"] = "<example>"
    parameters["adf_pfc"] = "<example>"
    parameters["adf_pfb"] = "<example>"
    parameters["adf_pt"] = "<example>"
    parameters["adf_pd"] = "<example>"
    parameters["adf_pw"] = "<example>"
    parameters["adf_pv"] = "<example>"
    parameters["adf_prr"] = "<example>"
    parameters["adf_pdw"] = "<example>"
    parameters["adf_pdh"] = "<example>"
    let request = YMAMutableAdRequest()
    request.age = age
    request.contextQuery = contextQuery
    request.contextTags = contextTags
    request.gender = gender
    request.location = location
    request.parameters = parameters
    interstitialAd = YMAInterstitialAd(adUnitID: "<AdUnitID>")
    interstitialAd.delegate = self
    interstitial.loadAd(with: request)
  4. Start displaying ads by using this method:

    func interstitialAdDidLoad(_ interstitialAd: YMAInterstitialAd) {
        interstitialAd.present(from: self)
    }
  5. You can optionally enable logging by using the +enableLogging method. If an impression wasn't registered, a message appears in the console.

To find out why ads aren't working correctly, use the methods
func interstitialAdDidFail(toLoad interstitialAd: YMAInterstitialAd, error: Error)
func interstitialAdDidFail(toPresent interstitialAd: YMAInterstitialAd, error: Error)

For error descriptions, see YMAAdErrorCode.

To see how the ad will be displayed in the app, use a demo AdUnitId:
  • demo-interstitial-yandex