Prerequisites
Create a wrapper
For creating a wrapper, you can follow this guide iOS Creating a wrapper, On this page, we present different ways to create the wrapper.
Show the Ad
The code snippet below demonstrates how to get the adWrapper
instance and display an outstream ad.
import UIKit import R89SDK class ViewController: UIViewController { ... @IBOutlet weak var adContainer: UIView! ... override func viewDidLoad() { super.viewDidLoad() ... let outstreamConfigId = ConfigBuilder.companion.VIDEO_OUTSTREAM_TEST_R89_CONFIG_ID RefineryAdFactory.shared.createVideoOutstreamBanner(configurationID: outstreamConfigId, wrapper: wrapper, lifecycleCallbacks: nil) } ... }
Your outstreamConfigId
will be provided to you during onboarding process by email, you can also retrieve them from the web interface after login.
They can be many or none depending on your requests, if you need one or more please request them to your account manager or technical account manager.
Lifecycle events
You can subscribe to these events with the same RefineryAdFactory.shared.createVideoOutstreamBanner(...)
method by passing an instance of BannerEventListener
for the lifecycleCallbacks
parameter. Details about this object can be found in the Reference.
First, extend from the BannerEventListener
. Next, provide the instance of BannerEventLogger
to RefineryAdFactory.shared.createVideoOutstreamBanner(...,:lifecycleCallbacks)
.
import UIKit import R89SDK // 1. Extend from the Banner EventListener private class OutstreamLivecycleListener : BannerEventListener { ... override func onLoaded() { // Ad has been loaded } ... } class ViewController: UIViewController { ... @IBOutlet weak var adContainer: UIView! ... override func viewDidLoad() { super.viewDidLoad() ... let outstreamConfigId = ConfigBuilder.companion.VIDEO_OUTSTREAM_TEST_R89_CONFIG_ID let outstreamLifecycleListener = OutstreamLivecycleListener() // 2. Pass the outstreamLifecycleListener instance via lifecycleCallbacks RefineryAdFactory.shared.createVideoOutstreamBanner(configurationID: ConfigBuilder.companion.VIDEO_OUTSTREAM_TEST_R89_CONFIG_ID, wrapper: adContainer, lifecycleCallbacks: outstreamLifecycleListener) } ... }