Interstitial

The VIS.X® SDK interstitial integration will provide you access to regular interstitials and our YOC Mystery Ad®, a high-impact full-screen overlay powered by YOC.

  1. Importing VisxSwiftUISDK to your View
  2. Initializing VisxInterstitial Manager
  3. Displaying the Interstitial
  4. Implementing VisxEvents
  5. Adding Background Color
Importing VisxSwiftUISDK to your View

First, import VisxSwiftUISDK into your View.

import VisxSwiftUISDK
Initializing VisxInterstitial Manager

A VisxInterstitial manager allows you to control the ad request display of an interstitial on your behalf. First, we will initialize the manager and loadAd() an interstitial, i.e. making an ad request to VIS.X®.

let interstitial = VisxInterstitial(adUnitId: "123456", 
                                    domain: "domain-of-your-app-ads-txt.com")
// start ad request
interstitial.loadAd()
Displaying the Interstitial

To display the previously loaded ad, you simply have to call the showAd() method.

interstitial.showAd()

Per default, there is a threshold of 30 minutes between loadAd() and showAd() in which the impression needs to be delivered, otherwise, the impression will expire. If required, the expiration timeout can be adjusted by YOC in exceptional cases.

To ensure there is an actual ad to show, it’s advised to implement VisxEvents and listen to the visxAdViewDidInitialize event, which is called when an ad request is successful and the ad is ready to be displayed.

Implementing VisxEvents

Instead of using Swift delegate methods, VisxInterstitial has a method that can receive all VisxEvents (e.g. visxAdViewDidInitialize, visxAdViewSizeChange, etc.) which are available for UIKit.

visxView.onEvent { visxEvent in
    // visxEvent is a VisxEvent enum of type string
    print("visxEvent: \(visxEvent)")
}
public enum VisxEvents: String {
    case visxAdViewDidInitialize
    case visxAdViewSizeChange
    case visxAdViewEffectChange
    case visxLandingPageOpened
    case visxAdViewClosed
    case visxAdViewClicked
    case visxAdVideoFinished
    case visxAdRequestStarted
    case visxAdInterstitialClosed
    case visxAdInterstitialWillBeClosed
    case visxAdResponseReceived
    case visxAdFailedWithError
    case appShouldResumeFromAd
    case appShouldSuspendForAd
    case visxAdViewDeallocated
	}
Adding Background Color

The default background color of interstitials is transparent with a slight opaque for visual separation from the content. If you need an opaque background, you may want to use the optional backgroundColor parameter from the init method.

let interstitial = VisxInterstitial(adUnitId: "123456", 
                                    domain: "domain-of-your-app-ads-txt.com",
                                    backgroundColor: .black)

Your interstitial placement is fully set up and ready for testing.

We advise you to share a build of your app with the YOC Service Team, to validate and fully test the integration together. Reach out to your contact at YOC to request test resources.