The VIS.X® SDK interstitial integration will provide you access to regular interstitials and the YOC Mystery Ad®, a high-impact fullscreen-overlay powered by YOC.
- Import VisxSDK to your UIViewController
- Initialize the VisxAdView
- Display VisxAdView as an Interstitial
- Adding Background Color
Import VisxSDK to your UIViewController
First, import VisxSDK
into your UIViewController
.
import VisxSDK
Initialize the VisxAdView
A VisxAdView
represents an instance of an ad you want to deliver and render as an Interstitial on top of your UIViewController
. You have the choice to use either delegates or closures as callbacks.
// Using the initializer with callbacks
adView = VisxAdView(adUnit: "123456",
adSize: CGSize(width: 300, height: 250),
viewControllerForPresenting: self,
interstitial: true)
adView?.load()
// Using the initializer with delegates
defaultAdView = VisxAdView(adUnit: "123456",
adViewDelegate: self,
adSize: CGSize(width: 320, height: 480),
interstitial: Bool? = true)
defaultAdView?.load()
Parameter | Description |
---|---|
adUnit |
VIS.X® Ad Unit ID (provided by YOC) |
adViewDelegate |
VisxAdViewDelegate , usually self |
adSize |
adSize is the default CGSize of your interstitial position |
viewControllerForPresenting |
ViewController which will present interstitial creative`. |
interstitial |
Has to be true . |
Display VisxAdView as Interstitial
Next, you need to either conform to the VisxAdViewDelegate
or Closures
as callbacks to render the ad using the .showInterstitial()
method of the VisxAdView
.
Using Closures
adView = VisxAdView(adUnit: "123456",
adSize: CGSize(width: 300, height: 250),
viewControllerForPresenting: self,
interstitial: true)
adView?.callbackHandler?
.onInitialize { [weak self] visxAdView, effect in
self?.adView?.showInterstitial()
}
.onError { [weak self] visxAdView, visxError in
print("visxAdFailedWithError: \(visxError)")
}
.onClose{ [weak self] visxAdView in
print("visxAdInterstitialClosed")
}
adView?.load()
Using Delegates
extension MysteryScrollViewController: VisxAdViewDelegate {
func viewControllerForPresentingVisxAdView() -> UIViewController! {
return self
}
func visxAdViewDidInitialize(_ visxAdView: VisxAdView, effect: VisxPlacementEffect) {
// Presents the interstitial from the default view controller.
adView?.showInterstitial()
}
//optional delegates
func visxAdFailedWithError(visxAdView: VisxAdView, message: String, code: Int) {
print("visxAdFailedWithError: message - \(message), status code - \(code)")
}
func visxAdInterstitialClosed(visxAdView: VisxAdView) {
print("visxAdInterstitialClosed")
}
}
Per default, there is a threshold of 30 minutes between load()
and showInterstitial()
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.
In case of no ad or any other error visxAdFailedWithError
delegate will provide additional information via an error message and an error code. All potential error codes and their meanings are listed here).
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, make sure to set up the color before rendering the ad, using the setInterstitialBackgroundColor(color: UIColor)
of VisxAdView
.
adView?.load()
adView?.setInterstitialBackgroundColor(.white)
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.