Prerequisites
Create a wrapper
For creating a wrapper, you can follow this small guide: Creating a Wrapper.
Show the Ad
This method below will add an ad to the provided wrapper
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 method by passing a new instance of BannerEventListener
as a lifecycleCallbacks
parameter to the createBanner
method. Details about this object can be found in the Reference.
First, extend from the BannerEventListener
. Here is what the implementation looks like.
class BannerEventLogger: BannerEventListener { override func onLayoutChange(width: Int32, height: Int32) { print("onLayoutChange","width=\(width)","height=\(height)") } override func onLoaded() { print("onLoaded") } override func onOpen() { print("onOpen") } override func onClick() { print("onClick") } override func onClose() { print("onClose") } override func onImpression() { print("onImpression") } override func onFailedToLoad(error: R89LoadError) { print("onFailedToLoad","error=\(error)") } }