The VideoAdUnit is a subclass of the AdUnit class. Use the VideoAdUnit object to create and configure a video outstream ad unit in your app.
Currently Google Ad Manager is the only supported ad server. We plan to provide support for additional ad servers in subsequent releases.
Create a new Video Outstream Ad Unit associated with a Prebid Server configuration ID and a video size.
See AdUnit for additional parameters and methods.
VideoAdUnit(configId: String, size: CGSize(width: Int, height: Int), type:Enum)
Parameters
configId(String)
: Prebid Server configuration ID.
size(CGSize)
: Width and height of the video ad unit.
type:Enum
: OpenRTB Placement Type.
Size of video ad unit.
Parameters
width
: Width of video ad unit in DIPs.
height
: Height of video ad unit in DIPs.
OpenRTB Placement Type represented as an enumeration of values:
inBanner
is transformed into OpenRTB value 2 to bid adaptersinArticle
is transformed into OpenRTB value 3 to bid adaptersinFeed
is transformed into OpenRTB value 4 to bid adaptersvideoAd (event: PBVideoAdEvent)
: Event to listen to.
Parameters
Events - one of the below event types:
See AdUnit for additional parameters and methods.
Google Mobile Ads
Import the GoogleMobileAds from google-mobile-sdk into the UIViewController displaying the VideoAdUnit.
Swift
var amBanner: DFPBannerView!
var adUnit: AdUnit!
func setupAndLoadAMBannerVAST() {
setupPBBannerVAST()
setupAMBannerVAST()
loadBanner()
}
func setupPBBannerVAST() {
Prebid.shared.prebidServerHost = .Rubicon
Prebid.shared.prebidServerAccountId = "accountId"
adUnit = VideoAdUnit(configId: "configId", size: CGSize(width: 300, height: 250), type: .inBanner)
}
func setupAMBannerVAST() {
setupAMBanner(id: "/5300653/test_adunit_vast_pavliuchyk")
}
func setupAMBanner(id: String) {
amBanner = DFPBannerView(adSize: kGADAdSizeMediumRectangle)
amBanner.adUnitID = id
}
func loadBanner() {
adUnit.fetchDemand(adObject: self.request) { [weak self] (resultCode: ResultCode) in
print("Prebid demand fetch for DFP \(resultCode.name())")
}
}